Many SCSS/SASS files to one CSS file?

I was having quite a frantic googling session trying to resolve this issue.
Turns out it's quite simple if you're using Rictwick Live Sass Compiler on VS Code.

  1. Make sure to save your sass/scss files starting with an underscore eg: _variables.scss, _mixin.scss.

  2. @import them into the main style.scss file you want to compile. Eg:

    @import "_mixins";
    @import "_variables";
    
  3. Pretty much that's it, you've compiled all your .scss files into a single CSS file.

You can tell SASS to watch an entire folder with:

sass --watch application/sass:public/stylesheets

If you import all your partial files, this should generate one file. Every time you edit a file in the folder, the CSS files will be generated automatically.


If you watch the directory, sass will be able to notice changes in @imported files, and update dependent files.

style.scss:

@import "header";
@import "footer";

And do:

sass --watch .

It will compile all files in the directory to .css; ignoring files whose name start with a _.

I you modify _header.scss or _footer.scss, if will update style.scss too.

You can also output in an other directory:

sass --watch .:output_dir/

Tags:

Html

Css

Sass