Skip to content

Instantly share code, notes, and snippets.

@ktkaushik
Last active January 21, 2016 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktkaushik/b3fc7aa4445e88c46bdf to your computer and use it in GitHub Desktop.
Save ktkaushik/b3fc7aa4445e88c46bdf to your computer and use it in GitHub Desktop.
primary grunt file
/**
*
*/
module.exports = function(grunt) {
var timestamp = new Date().getTime() + '';
var pkg = grunt.file.readJSON('package.json');
// 1. All configuration goes here
grunt.initConfig({
pkg: pkg,
watch: {
scripts: {
files: ['assets/js/**/*.js', 'assets/js/*.js'],
tasks: ['js-task']
},
css: {
files: ['assets/less/*.less'],
tasks: ['css-task']
}
},
concat: {
options: {
separator: ';'
},
dist: {
src: ['assets/js/*.js', 'assets/js/**/*.js'],
dest: 'public/primary.js'
}
},
less: {
production: {
options: {
paths: ['assets/less']
},
files: {
'public/css/master.css': 'assets/less/master.less'
}
}
},
cssmin: {
options: {
shorthandCompacting: false
},
plugin: {
files: {
'public/css/master.min.css': ['public/css/master.css']
}
}
}
});
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'less:production', 'cssmin']);
grunt.registerTask('js-task', ['concat']);
grunt.registerTask('css-task', ['less:production', 'cssmin']);
grunt.registerTask('less', ['less:production']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment