Skip to content

Instantly share code, notes, and snippets.

@sillero
Last active December 29, 2015 18:09
Show Gist options
  • Save sillero/7709078 to your computer and use it in GitHub Desktop.
Save sillero/7709078 to your computer and use it in GitHub Desktop.
Grunt + (Compass + Sourcemaps)

##Install 1 - Node + NPM: http://nodejs.org/download/
2 - Ruby: http://rubyinstaller.org/downloads/
3 - Run:

gem install compass-sourcemaps --pre
npm install grunt-contrib-watch grunt-contrib-compass --save
// create Gruntfile.js as below, then proceed to next line
grunt init

##Gruntfile.js grunt.initConfig({ compass: { styles: { options: { raw: 'sass_options = {:sourcemap => true}\n', sassDir: 'scss', cssDir: 'css', outputStyle: 'expanded', assetCacheBuster: false } } }, compass_is_fixed: false, watch: { styles: { files: ['scss/**/*.scss'], tasks: ['compass:styles'] } } }); grunt.registerTask('default', ['watch']); grunt.registerTask('init', ['compass-fix', 'default']); grunt.registerTask('compass-fix', 'Fix compass -> sourcemap compatibility', function(){ if (!grunt.config('compass_is_fixed')) { var filename = 'node_modules/grunt-contrib-compass/tasks/compass.js', contents = grunt.file.read(filename);

        contents = contents.replace(/if\s+\(\!options\.clean\)\s+\{\s+options.time\s+\=\s+true\;\s+\}/,'//if (!options.clean) {options.time = true;}');
        grunt.file.write(filename, contents);
        grunt.config('compass_is_fixed', true);
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment