Skip to content

Instantly share code, notes, and snippets.

@chrisvasey
Created August 12, 2016 13:13
Show Gist options
  • Save chrisvasey/d7dfa6f39dab8b647dd13e3129252353 to your computer and use it in GitHub Desktop.
Save chrisvasey/d7dfa6f39dab8b647dd13e3129252353 to your computer and use it in GitHub Desktop.
LESS + BrowserSync for static sites
/*
npm install -g grunt-cli
npm init
npm install grunt grunt-contrib-less grunt-contrib-watch jit-grunt grunt-browser-sync --save-dev
grunt
*/
module.exports = function(grunt) {
require('jit-grunt')(grunt);
grunt.initConfig({
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"css/main.css": "css/main.less" // destination file and source file
}
}
},
watch: {
styles: {
files: ['css/**/*.less'], // which files to watch
tasks: ['less'],
options: {
nospawn: true
}
}
},
browserSync: {
dev: {
bsFiles: {
src : [
'css/*.css',
'*.html'
]
},
options: {
watchTask: true,
server: './'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.registerTask('default', ['browserSync','less', 'watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment