Skip to content

Instantly share code, notes, and snippets.

@haoch
Created December 30, 2013 15:31
Show Gist options
  • Save haoch/8183473 to your computer and use it in GitHub Desktop.
Save haoch/8183473 to your computer and use it in GitHub Desktop.
nodejs: npm with grunt
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'Gruntfile.js',
'assets/js/*.js',
'assets/js/plugins/*.js',
'!assets/js/main.min.js'
]
},
recess: {
dist: {
options: {
compile: true,
compress: true
},
files: {
'assets/css/main.min.css': [
'assets/less/main.less'
]
}
}
},
uglify: {
dist: {
files: {
'assets/js/main.min.js': [
'assets/js/plugins/*.js',
'assets/js/_*.js'
]
}
}
},
watch: {
less: {
files: [
'assets/less/*.less'
],
tasks: ['recess']
},
js: {
files: [
'<%= jshint.all %>'
],
tasks: ['uglify']
}
},
clean: {
dist: [
'assets/css/main.min.css',
'assets/js/main.min.js'
]
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess');
// Register tasks
grunt.registerTask('default', [
'clean',
'recess',
'uglify'
]);
grunt.registerTask('dev', [
'watch'
]);
};
{
// ...
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.5.2",
"grunt-recess": "~0.3.5"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment