Ignore SASS and LESS Partials (Starting with Underscore) when Using SublimeOnSaveBuild

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.

Here’s a basic explanation of the regex in the filename_filter:

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 \\ and \. 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.

Hey Josh, the solution to this problem is downloading a plug-in called “auto-save”. After you make the regex change you recommend above, when you go to your partials and make a change, they are automatically saved (but not build because of above). With the combination of the two, workflow is very easy!

You can use the <pre> tag to post a block of code, or <code> to highlight code within text.

Get In Touch

I’m a freelance front-end web developer/programmer, with an eye for design.
I enjoy making clean, functional, and detail-oriented websites using the latest
HTML5, CSS, JavaScript and PHP. Lately I've been working a lot with WordPress.Status: Not Accepting Work at this Time

Scripts & Projects

An NPC creator for fantasy RPGs. Geared towards D&D, Pathfinder, and other table-top games. Creates a random character with various physical and personality traits, armor & weapons, inventory items, and more, to help with roleplaying and backstory.