Skip to content

Instantly share code, notes, and snippets.

@milmazz
Last active Aug 29, 2015
Embed
What would you like to do?
Grunt: The Javascript Task Manager
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jsdoc : {
dist : {
src: ['src/*.js', 'test/*.js'],
dest: 'doc'
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: ['Gruntfile.js', 'src/*.js', 'test/*.js']
},
jsbeautifier: {
modify: {
src: 'index.js',
options: {
config: '.jsbeautifyrc'
}
},
verify: {
src: ['index.js'],
options: {
mode: 'VERIFY_ONLY',
config: '.jsbeautifyrc'
}
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'dist/index.html': 'src/index.html', // 'destination': 'source'
'dist/contact.html': 'src/contact.html'
}
}
},
cssmin: {
add_banner: {
options: {
banner: '/* My minified css file */'
},
files: {
'path/to/output.css': ['path/to/**/*.css']
}
}
},
uglify: {
options: {
banner: '/* <%= grunt.template.today("yyyy-mm-dd") %> */\n',
separator: ',',
compress: true,
},
chart: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
});
// Load the plugin that provides the 'jsdoc' task.
grunt.loadNpmtasks('grunt-jsdoc');
// Load the plugin that provides the 'jshint' task.
grunt.loadNpmTasks('grunt-contrib-jshint');
// Load the plugin that provides the 'jsbeautifier' task.
grunt.loadNpmTasks('grunt-jsbeautifier');
// Load the plugin that provides the 'uglify' task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Load the plugin that provides the 'htmlmin' task.
grunt.loadNpmTasks('grunt-contrib-htmlmin');
// Load the plugin that provides the 'cssmin' task.
grunt.loadNpmTasks('grunt-contrib-cssmin');
// Wrapper around htmlmin, cssmin and uglify tasks.
grunt.registerTask('minified', [
'htmlmin',
'cssmin',
'uglify'
]);
// Default task
grunt.registerTask('default', ['jshint']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment