2

当我运行时,grunt我在终端上得到这个输出。

运行“concat:dist”(concat)任务
文件 ../web/js/main.js 创建。

运行“uglify:dist”(uglify)任务

运行“compass:dist”(罗盘)任务
不变的master.scss
编译耗时 0.093s

运行“autoprefixer:dist”(自动前缀)任务

完成,没有错误。

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']);
};
4

0 回答 0