sass import compiler
This plugin is for developers who use the watch contrib to compile their scss on file updates. It allows you to manage your main scss file @import's in a config array in your gruntfile. This way you do not have to do the duplicitive work of managing an array of scss files to watch and updating a list of files to import in your primary scss file.
At it's simplest this plugin takes an array of scss files like this:
And writes an scss file that looks like this:
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install sass-import-compiler --save-dev
The "sass_import_compiler" task
In your project's Gruntfile, add a section named
sass_import_compiler to the data object passed into
If set to true
.scss file extensions will not be removed from paths when writing them to them in the destination file.
In this example, src/main.scss will be written to contain the three files below as @import partials.
For this configuration, the contents of src/main.scss will be:
I created this plugin with the idea of using it in tandem with the grunt watch contrib. The thought being that you maintain your scss dependencies in an array outside the grunt config, and then only have to maintain them in one place. You use watch to compile on any file updates and you use watch to monitor any change to your configuration and re-compile your scss @import list on your main file.
First you would have to manage your scss dependencies in a seperate array. This could be before your grunt.initConfig in gruntfile.js or in a seperate config file you require.
var scss_dependencies ='src/vars.scss''src/mixins.scss''src/header.scss';
Then set up your grunt config so the sass plugin compiles from your sass_import_compiler destination file. Set up watch to run the sass task to any update to a file in scss_dependencies, and to run the sass_import_comiler task whenever the file containing scss_dependencies updates (in this case we'll assume it's managed in gruntfile.js).
Copyright (c) 2014 Justin Worsdale. Licensed under the MIT license.