当我运行grunt
时,我在终端上获得此输出。
Running "concat:dist" (concat) task File ../web/js/main.js created. Running "uglify:dist" (uglify) task Running "compass:dist" (compass) task unchanged master.scss Compilation took 0.093s Running "autoprefixer:dist" (autoprefixer) task Done, without errors.
uglify和autoprefixer不显示任何输出
但是当我运行grunt -v
时:
Running "concat" task
Running "concat:dist" (concat) task
Verifying property concat.dist exists in config...OK
Files: lot of files, ../js/eug/eug-main.js -> ../web/js/main.js
Options: separator=";", banner="", footer="", stripBanners=false, process=false, sourceMap=false, sourceMapName=undefined, sourceMapStyle="embed"
Reading ../js/vendor/eug-jquery-1.11.1.js...OK
Reading ..more files.......OK
Writing ../web/js/main.js...OK
File ../web/js/main.js created.
Running "uglify" task
Running "uglify:dist" (uglify) task
Verifying property uglify.dist exists in config...OK
Files: ../web/js/main.js -> ../web/js/main.min.js
Options: banner="", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="gzip", expression=false
Minifying with UglifyJS...Reading ../web/js/main.js...OK
OK
Writing ../web/js/main.min.js...OK
File ../web/js/main.min.js created: 735.15 kB → 222.43 kB → 69.05 kB (gzip)
Running "compass" task
Running "compass:dist" (compass) task
Verifying property compass.dist exists in config...OK
File: [no files]
Options: sassDir="dirs", outputStyle="compressed", noLineComments=false, cacheDir="../sass/.sass-cache/"
unchanged master.scss
Compilation took 0.084s
Running "autoprefixer" task
Running "autoprefixer:dist" (autoprefixer) task
Verifying property autoprefixer.dist exists in config...OK
Options: cascade, diff=false, map=false, browsers=["Android 2.3","Android >= 4","Chrome >= 20","Firefox >= 24","Explorer >= 8","iOS >= 6","Opera >= 12","Safari >= 6"]
Done, without errors.
uglify工作,写入文件输出并显示文件报告。
为什么没有-v不能正常工作?我记得它以前用它在终端显示它。
这是我的Gruntfile.js
module.exports = function(grunt) {
// init config
grunt.initConfig({
// read package.json
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
dist: {
src: [
'../js/vendor/eug-jquery-1.11.1.js',
'..more files..'
'../js/eug/*.js'
],
dest: '../web/js/main.js' // merged file
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> */\n',
report: 'gzip'
},
dist: {
files: {
'../web/js/main.min.js': ['<%= concat.dist.dest %>'] // output file.
}
}
},
compass: {
dist: {
options: {
sassDir: '../sass/scss/',
cssDir: '../web/css/',
imagesDir: '../web/images/',
outputStyle: 'compressed', // nested / expanded / compact / compressed
noLineComments: false,
cacheDir: '../sass/.sass-cache/'
}
}
},
autoprefixer: {
dist: {
options: {
browsers: ['Android 2.3','Android >= 4','Chrome >= 20','Firefox >= 24','Explorer >= 8','iOS >= 6','Opera >= 12','Safari >= 6']
},
files: [{
expand: true,
cwd: './web/css/',
src: '{,*/}*.css',
dest: './web/css/'
}]
}
},
watch: {
compass: {
files: ['../sass/scss/**/*.scss'],
tasks: ['compass'], // on change execute
options: {
spawn: false,
},
},
scripts: {
files: ['../js/**/*.js'],
tasks: ['concat'], // on change execute
options: {
spawn: false,
},
}
},
});
// load tasks
grunt.loadNpmTasks('grunt-contrib-watch'); // file watcher
grunt.loadNpmTasks('grunt-contrib-concat'); // concat js files
grunt.loadNpmTasks('grunt-contrib-uglify'); // minify js files
grunt.loadNpmTasks('grunt-contrib-compass'); // compass compiler
grunt.loadNpmTasks('grunt-autoprefixer'); // autoprefixer css
// register tasks
grunt.registerTask('test', []);
grunt.registerTask('default', []);
grunt.registerTask('listen', ['watch']);
grunt.registerTask('prod-init', ['concat', 'uglify', 'compass', 'autoprefixer']);
};