Skip to content

Instantly share code, notes, and snippets.

@marcofranssen
Created March 15, 2014 13:30
Show Gist options
  • Save marcofranssen/9567273 to your computer and use it in GitHub Desktop.
Save marcofranssen/9567273 to your computer and use it in GitHub Desktop.
grunt.registerTask('ci', ['jshint', 'concat', 'uglify', 'less', 'cssmin']);
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
//other tasks left for brevity
watch: {
scripts: {
files: 'js/**/*.js',
tasks: ['jshint', 'mocha:unittest', 'phantom']
},
less: {
files: 'less/**/*.less',
tasks: ['less']
},
styles: {
files: 'css/**/*.css',
tasks: ['cssmin']
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
};
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */'
},
secret: grunt.file.readJSON('secret.json'),
jshint: {
options: {
jshintrc: '.jshintrc'
},
gruntfile: ['Gruntfile.js'],
serverside: ['server/src/**/*.js', 'server/*.js'],
clientside: ['js/cors/*.js', 'js/*.js', '!js/thirdparty/**'],
tests: ['test/**/*.js']
},
concat: {
options: {
stripBanners: true,
banner: '<%= meta.banner %>'
},
javascript: {
files: {
'build/js/myawesomeapplication.js': [
'js/thirdparty/jquery.iframe-transports.js', 'js/app.js', 'js/validation.js',
'js/controller.js', 'js/router.js', 'js/modules/**/*.js'
]
},
nonull: true
}
},
uglify: {
options: {
banner: '<%= meta.banner %>',
compress: {
drop_console: true,
sequences: true, // join consecutive statemets with the “comma operator”
properties: true, // optimize property access: a["foo"] → a.foo
dead_code: true, // discard unreachable code
drop_debugger: true, // discard “debugger” statements
unsafe: false, // some unsafe optimizations (see below)
conditionals: true, // optimize if-s and conditional expressions
comparisons: true, // optimize comparisons
evaluate: true, // evaluate constant expressions
booleans: true, // optimize boolean expressions
loops: true, // optimize loops
unused: true, // drop unused variables/functions
hoist_funs: true, // hoist function declarations
hoist_vars: false, // hoist variable declarations
if_return: true, // optimize if-s followed by return/continue
join_vars: true, // join var declarations
cascade: true, // try to cascade `right` into `left` in sequences
side_effects: true, // drop side-effect-free statements
warnings: true
},
report: 'gzip'
},
javascript: {
files: {
'build/js/myawesomeapplication.min.js': ['build/js/myawesomeapplication.js']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['']);
grunt.registerTask('minify', ['concat', 'uglify']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment