grunt打包工具使用

package.json

{
"name": "**",
"version": "0.1.0",
"author": "Amanda",
"description": "**",
"dependencies": {
"grunt": "*",
"grunt-contrib-clean": "*",
"grunt-contrib-compress": "*",
"grunt-contrib-copy": "*",
"grunt-contrib-cssmin": "*",
"grunt-contrib-htmlmin": "*",
"grunt-contrib-uglify": "*",
"grunt-strip-debug": "^1.1.0"
},
"devDependencies": {
"gulp": "^3.9.1"
}

Gruntfile.js

module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

stripDebug: {
dist: {
files: {
'***.js': '***.js'
}
}
},
uglify: {
scripts: {
files: {
'**.min.js':'**.js'

}
}
}

});


grunt.loadNpmTasks('grunt-strip-debug');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['stripDebug','uglify']);

};

命令:

npm install -g grunt-cli

npm install

gulp

原文地址:https://www.cnblogs.com/amandaff/p/7910019.html