Skip to content

Instantly share code, notes, and snippets.

@jongha
Created March 27, 2015 02:48
Show Gist options
  • Save jongha/19f20a160bf9e546cdea to your computer and use it in GitHub Desktop.
Save jongha/19f20a160bf9e546cdea to your computer and use it in GitHub Desktop.
My Gruntfile.js sample
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: ['static/assets/user/bare'],
jshint: {
files: ['Gruntfile.js', 'static/assets/user/js/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
coffee: {
options: {
bare: true
},
compile: {
files: {
'static/assets/user/bare/js/coffee.js': ['static/assets/user/coffee/**/*.coffee']
}
}
},
concat: {
options: {
stripBanners: true,
banner: '/*!\n' +
' * <%= pkg.name %>\n' +
' * <%= pkg.url %>\n' +
' * @author <%= pkg.author %>\n' +
' * @version <%= pkg.version %>\n' +
' * Copyright <%= pkg.copyright %>. <%= pkg.license %> licensed.\n' +
' */\n'
},
dist: {
src: ['static/assets/user/bare/js/**/*.js', 'static/assets/user/js/**/*.js'],
dest: 'static/assets/user/dist/js/script.js',
}
},
uglify: {
options: {
mangle: {
except: ['jQuery']
}
},
dist: {
options: {
sourceMap: true,
sourceMapName: 'static/assets/user/dist/js/script.map'
},
files: {
'static/assets/user/dist/js/script.min.js': ['static/assets/user/dist/js/script.js']
}
}
},
less: {
production: {
options: {
compress: true,
cleancss: true,
paths: ['static/assets/less']
},
files: {
'static/assets/user/dist/css/style.css': 'static/assets/user/less/style.less'
}
}
},
watch: {
options: {
dateFormat: function(time) {
grunt.log.writeln('The watch finished in ' + time + 'ms at' + (new Date()).toString());
grunt.log.writeln('Waiting for more changes...');
},
},
files: ['<%= jshint.files %>', 'static/assets/user/less/**/*.less', 'static/assets/user/coffee/**/*.coffee'],
tasks: ['jshint', 'coffee', 'concat', 'uglify', 'less', 'clean']
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-clean');
// for default task
grunt.registerTask('default', ['jshint', 'coffee', 'concat', 'uglify', 'less', 'clean']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment