Now, while I am developing my project I have three files, "main.css", "about.css" and "news.css" (for example). Is it possible to compile them into one "final.css" for production?
Once Sass is installed, you can compile your Sass to CSS using the sass command. You'll need to tell Sass which file to build from, and where to output CSS to. For example, running sass input.scss output.css from your terminal would take a single Sass file, input.scss , and compile that file to output.css .
Sass Importing Files The @import directive allows you to include the content of one file in another. The CSS @import directive has a major drawback due to performance issues; it creates an extra HTTP request each time you call it.
Compass is an open-source CSS authoring framework which uses the Sass stylesheet language to make writing stylesheets powerful and easy.
The SASS import directive is used to import the contents of one file into another, so you could create a file final.scss
whose contents are:
@import 'main';
@import 'about';
@import 'news';
You'd then need to rename your files to have "scss" extensions so the import directive will find them. If you don't want the main.scss
, about.scss
, and news.scss
files to compile to CSS files themselves, you can use partials by prefixing the filenames with an underscore (i.e., _main.scss
, _about.scss
, _news.scss
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With