sasscompilationpartials

How to make Sass not to compile my partial files?


I'm trying to make my SCSS files more modular by splitting it into individual partial files. It's all well until suddenly I have a bunch of .css and .css.map files in my partials directory because I've, naturally, saved all of them, and the Sass watcher dutifully compiled all of them too.

How do I achieve a clean structure like Bootstrap's while not having to manually delete every partial .css files? Ideal scenario is that every time I edit and save the partial files, Sass watcher compiles only the main .scss file.

I'm using VS Code on Mac with a Sass watcher plugin. Is it achievable in this environment?


Solution

  • https://sass-lang.com/guide

    A partial is simply a Sass file named with a leading underscore. You might name it something like _partial.scss. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the @import directive. (@import is soon to be deprecated, with a move to @use and @forward instead. https://sass-lang.com/documentation/at-rules/import)

    Thanks Arkellys.