Johan Alkstål
Johan Alkstål

Reputation: 5347

Webstorm 6 - How to make the scss file watcher ignore files

I would like the file watcher for SCSS files to ignore files with file names starting with an underscore, for example _buttons.scss.

How would I do that?

Upvotes: 2

Views: 3054

Answers (2)

cjbarth
cjbarth

Reputation: 4479

@LazyOne has the right idea. A Scope can be created that excludes files that being with an underscore (_). The page at http://www.jetbrains.com/phpstorm/webhelp/scopes.html#d437174e402 has more information about this, but basically you select the folder you want after creating a custom scope and then in the scope field append it again with && ! between the two and exclude files starting with an underscore.

For example:

file:website/css//* && !file:website/css//_*

Upvotes: 1

allcaps
allcaps

Reputation: 11248

Start by adding a _ to a file that you want to be ignored... Done! From the documentation:

Partials

If you have a SCSS or Sass file that you want to import but don’t want to compile to a CSS file, you can add an underscore to the beginning of the filename. This will tell Sass not to compile it to a normal CSS file. You can then import these files without using the underscore.

For example, you might have _colors.scss. Then no _colors.css file would be created, and you can do

@import "colors";

So adding an underscore will do the job. Just don't import.

Be careful naming your files because if you have a style.scss and _style.scss Sass will see these as the same filename and trow an error:

>>> Change detected to: /Users/allcaps/test/style.scss
WARNING: In /Users/allcaps/test:
  There are multiple files that match the name "style.scss":
    _style.scss
    style.scss

A simple workaround will be to add two underscores: __style.scss.

Upvotes: 4

Related Questions