Grunt.js 在前端项目中的实战
http://beiyuu.com/grunt-in-action/
{ "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-cssmin": "~0.6.1", "grunt-contrib-uglify": "~0.2.2", "grunt-contrib-imagemin": "~0.1.4", "grunt-regarde": "latest", "grunt-contrib-connect": "latest", "grunt-contrib-livereload": "latest" } }
module.exports = function(grunt) { grunt.initConfig({ sass: { compile: { files: { 'css/core.css': ['css/core.scss'] } } }, cssmin: { combine: { files: { 'css/core.css': ['css/core.css'] } } }, uglify: { options: { mangle: false }, build: { files: { 'js/core.js': ['js/core.js'] } } }, imagemin: { dist: { options: { optimizationLevel: 3 }, files: [{ expand: true, cwd: 'imgsss/', src: ['**/*.{png,jpg,jpeg}'], dest: 'imgssss/' }] } }, watch: { scripts: { files: [ 'css/*.scss', 'js/*.js' ], tasks: ['sass', 'cssmin', 'uglify'] } } }); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-imagemin'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.registerTask('default', ['sass', 'cssmin', 'uglify', 'imagemin', 'watch']); };
grunt
grunt.registerTask('default', ['less', 'watch']);
grunt build
grunt.registerTask('build', ['htmlmin', 'uglify', 'cssmin', 'imagemin']);
grunt live
grunt.registerTask('live', ['livereload-start', 'connect', 'regarde']);
xp系统node_modules里文件目录层级太深不能删除需要把文件剪切出来删除