blogs icon indicating copy to clipboard operation
blogs copied to clipboard

Compile multiple scss files

Open hugronaphor opened this issue 8 years ago • 6 comments

Is there a way to compile multiple scss files?

hugronaphor avatar Apr 14 '18 12:04 hugronaphor

Yes, can you elaborate on what you're trying to do?

hellobrian avatar Apr 16 '18 15:04 hellobrian

@hellobrian Supposedly I have this structure.

├── css │ └── style.css ├── scss │ └── style.scss │ └── forms.scss

I want to keep my sass files split into different files but have only one after the compilation.

This is what my current setup look like:

"scripts": {
    "sass": "node-sass --include-path scss scss/style.scss css/style.css --output-style compressed",
    "watch:sass": "npm run sass -- --watch"
  },

hugronaphor avatar Apr 16 '18 15:04 hugronaphor

With node-sass, you can keep your scss files compiling to separate files by writing new scripts. So to allow forms.scss to compile to forms.css:

"scripts": {
  "form-sass": "node-sass --include-path scss scss/form.scss css/form.css --output-style compressed"
}

Or if you're okay with always having your scss files compile to seperate css files, then you can rely on using this script:

"scripts": {
  "sass": "node-sass scss --include-path scss --output css --output-style compressed",
}
  • instead of giving node-sass specific files, you can give it directories for input and output but make sure to add the --output flag when working with directories.

See the docs here: https://github.com/sass/node-sass#usage-1

hellobrian avatar Apr 16 '18 16:04 hellobrian

OK, "sass": "node-sass scss --include-path scss --output css --output-style compressed", seems like what I need but, is there a way to merge all the files from the scss directory in one css file?

hugronaphor avatar Apr 16 '18 16:04 hugronaphor

Your original script will merge all scss files into one css file but you have to make sure you're writing @import statements in your main scss file.

hellobrian avatar Apr 16 '18 16:04 hellobrian

This is what I was looking for: @import Thanks

hugronaphor avatar Apr 16 '18 19:04 hugronaphor