Skip to content

Instantly share code, notes, and snippets.

@georgicodes
Created February 23, 2014 22:09
Show Gist options
  • Save georgicodes/9178054 to your computer and use it in GitHub Desktop.
Save georgicodes/9178054 to your computer and use it in GitHub Desktop.
module.exports = function(grunt) {
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
// target.css file: source.less file
"css/styles.css": "less/styles.less"
}
}
},
watch: {
styles: {
// Which files to watch (all .less files recursively in the less directory)
files: ['myLessDir/less/**/*.less'],
tasks: ['less'],
options: {
nospawn: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['watch']);
};
@georgicodes
Copy link
Author

This is a Gruntfile.js example for LESS. It watches a directory and compiles the LESS file into a CSS file. Remember to first add devDependencies to package.json, then npm install. You can just run grunt and it will watch an compile

"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-less": "~0.5.0",
"grunt-contrib-watch": "~0.4.0"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment