Cascadium is a lightweight CSS preprocessor for CSS.
This small project can compile CSS with superpowers into a flat CSS file that is more compatible with a larger number of browsers. The project was written in C# and can run on any operating system without the installation of .NET.
Cascadium, unlike other preprocessors, tends to be an extension of CSS and not another markup or programming language. It has some developer-specific features, but all of them are focused on still being "CSS."
Main features:
- Convert nested CSS into flat CSS
- Single-line comments
- Minification, compression, and merging of CSS files
- Custom property converters
- Rewrite media queries
Install Cascadium with NPM:
npm install -g @cypherpotato/cascadiumAnd then, just run it from the command line:
cascadium-
- 3.1. Syntax
-
- 4.1. KeepNestingSpace
- 4.2. Pretty
- 4.3. UseVarShortcut
- 4.4. Merge
-
- 5.1. Configuration File
- 5.2. Watch
- 5.3. InputDirectories
- 5.4. InputFiles
- 5.5. Exclude
- 5.6. Extensions
- 5.7. OutputFile
- 5.8. FilenameTag
- 5.9. AtRulesRewrites
You can use the library in your C# project or use the command-line tool compatible with any type of project.
To use the library in your code, you can start by adding the reference to Cascadium:
dotnet add package Cascadium.CompilerAnd use it as in the example below:
static void Main(string[] args)
{
string xcss = """
div {
color: red;
> span {
color: blue;
font-weight: 500;
}
}
""";
var stylesheet = CascadiumCompiler.Parse(xcss);
var css = stylesheet.Export();
Console.WriteLine(css);
}And get the result:
div{color:red}div>span{color:blue;font-weight:500}The goal of Cascadium is to be as faithful to the original CSS as possible. Therefore, you will not find a similar experience to what SASS or LESS offers: there will be no preprocessor variables, no mixins, loops, etc. Cascadium should be seen as an extension of CSS, not as a language like SASS or LESS.
Creating entire projects with SCSS is possible, with pure CSS as well, so it will be with Cascadium too. The main advantage of Cascadium is being flexible enough to be integrated into any type of project, as its generator can produce CSS files equivalent to the typed Cascadium code.
Currently, Cascadium can be used in two ways:
- CLI: through the Cascadium tool binaries, which allows usage in any project of any programming language.
- .NET Package: the .NET library of Cascadium, which allows the use of the compiler in a managed development environment.
For detailed information about syntax, compiler settings, CLI configuration, and converters, please refer to the Cascadium Specification.