I’ve recently started using SASS and LESS with Sublime Text. The most popular recommended extensions for SASS were “SASS” for highlighting, “SASS Build” for compiling, and “SublimeOnSaveBuild” to auto build whenever you save.
The problem with the build on save is that it currently does not ignore partials. Partials are additional files starting with an underscore that you import into your main SASS file, e.g. _vars.scss or _typography_scss.
The settings for the package allows you to set a regular expression for the filename that is built. The only way that I could think to fix this is to modify this regular expression to exclude files starting with an underscore. To edit this file, go to Preferences -> Package Settings -> SublimeOnSaveBuild -> Settings – User. It’s best to edit the User preferences rather than the Default preferences, so they will be preserved after upgrading.
I’ve also tried this out on the regex tester pythex.org: View Regex Tester
Here’s a basic explanation of the regex in the filename_filter:
- Matches backslash, forward slash, or is start of string
- Does not then have an underscore
- Matches any number of alphanumeric and underscores (w)
- Matches period, and file extension, then end of string with $ (default)
Note that you need to do an extra escape on the forward slashes to get them to work in Sublime text, hence the
\. There is an error in parsing without them.
There’s this relief and elation one feels when a tricky regex finally works. Phew. If this doesn’t work for you, let me know. I’m no regex master, so feel free to drop in any improvements. Hopefully this will be added to the package by default in the future.