grunt 记录2

module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);

    var path = {
        src : 'src',
        dest : 'dist',
        tmp : '.tmp'
    }

    grunt.initConfig({
        path : path,
        clean : {
            beforebuild : {
                files : [{
                        src : ['<%= path.dest %>/', '<%= path.tmp %>/']
                    }
                ]
            }
        },
        filerev : {
            build : {
                files : [{
                        src : ['<%= path.dest %>/**', '!<%= path.dest %>/**/*.html']
                    }
                ]
            }
        },
        useminPrepare : {
            build : {
                options: {
                    root: [
                        '<%= path.src %>','<%= path.src %>/html','<%= path.src %>/image','<%= path.src %>/js'//也可以'<%= path.src %>/**'
                    ],
                    dest:'<%= path.dest %>/html'
                },
                files : [{
                        src : '<%= path.src %>/**/*.html'
                    }
                ]
            }
        },
        usemin : {
            options: {
                assetsDirs: [
                    '<%= path.dest %>','<%= path.dest %>/html','<%= path.dest %>/image','<%= path.dest %>/js'
                ],
                patterns:{
                    js:[
                        [/(image\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the Js to reference our revved images']
                    ]
                }
            },
            html : {
                files : [{
                        src : '<%= path.dest %>/**/*.html'
                    }
                ]
            },
            css : {
                files : [{
                        src : '<%= path.dest %>/css/**/*.css'
                    }
                ]
            },
            js : {
                files : [{
                        src : '<%= path.dest %>/js/**/*.js'
                    }
                ]
            }
        },
        copy : {
            build : {
                files : [{
                        expand : true,
                        cwd : '<%= path.src %>/',
                        src : ['**/*.html'],
                        dest : '<%= path.dest %>/'
                    }
                ]
            }
        },
        imagemin : {
            build : {
                files : [{
                        expand : true,
                        cwd : '<%= path.src %>',
                        src : ['**/*.{jpg, png, jpeg, gif}'],
                        dest : '<%= path.dest %>/'
                    }
                ]
            }
        }
    });
    grunt.registerTask('default', ['clean:beforebuild', 'copy', 'imagemin', 'useminPrepare', 'concat', 'cssmin', 'uglify', 'filerev', 'usemin']);
};

没有解决 Different sources attempting to write to the same destination 问题。

posted @ 2016-07-04 12:42  冬暑  阅读(181)  评论(0编辑  收藏  举报