//npm package manager
{
"name": "2016-12-16-grunt",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-cssmin": "^1.0.2",
"grunt-contrib-uglify": "^2.0.0"
}
}
//gruntfile.js configuration information
module.exports = function(grunt){
// project configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',//添加banner
beautify: {
//Chinese ascii, very useful! God configuration to prevent Chinese garbled characters
ascii_only: true
}
},
buildall: {//Compress all JS files in the js folder according to the original file structure
files: [{
expand:true,
cwd:'origin_js',//under the js directory
src:'**/*.js',//all js files
dest: 'js'//output to this directory
}]
}
},
cssmin: {
//file header output information
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
//beautify the code
beautify: {
//Chinese ascii, very useful! God configuration to prevent Chinese garbled characters
ascii_only: true
}
},
my_target: {
files: [
{
expand: true,
//relative path
cwd: 'origin_stylesheets/',
src: '**/*.css',
dest: 'stylesheets'
}
]
}
}
});
// Load the plugin that provides the "uglify" task
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
// default task
grunt.registerTask('default', ['uglify', 'cssmin']);
// grunt.registerTask('default', ['uglify:buildall','cssmin']);
// grunt.registerTask('minall', ['uglify:buildalls','cssmin']);
}