Created
December 30, 2013 15:31
-
-
Save haoch/8183473 to your computer and use it in GitHub Desktop.
nodejs: npm with grunt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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' | |
]); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// ... | |
"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