8

私はうなり声が初めてです。プロジェクトには 20 ~ 30 個近くの js ファイルがあります。私たちはすでに grunt を使用してそれらを縮小および連結していることを知りました。デバッグ目的で、縮小を停止する必要がありますが、それらを連結形式で保持する必要があります。誰でも続行方法を提案できますか。関連するチュートリアルがあるサイトは役に立ちます。よろしくお願いします。

module.exports = function(grunt) {
 var readJSFile = function(data, path){
    var finalArray = [];
    if(path == 'assets/js/'){
        finalArray.push('<%= copy.options.buildFolder %>/JSON-words.js');
    }
    for(var item in data.main){
        finalArray.push('<%= copy.options.buildFolder %>/'+path+data.main[item].file);
    }
    return finalArray;
}
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    exec: {
        update: {
            command: 'TortoiseProc.exe /command:update /path:"./**" /closeonend:3'
        }
    },
    copy: {
        options : {
            buildFolder : '../../deliverables/<%= pkg.folder %>/<%= grunt.template.today("yyyymmdd") %>-htdocs'
        },
        main: {
            files: [
                {expand: true, src: ['./**'], dest: '<%= copy.options.buildFolder %>'}
            ]
        }
    }, 
    'useminPrepare': {
        html: ['<%= copy.options.buildFolder %>/inc/general/head.html', '<%= copy.options.buildFolder %>/inc/general/foot.html', '<%= copy.options.buildFolder %>/inc/module/print.html']
    },
    usemin: {
      html: ['<%= copy.options.buildFolder %>/inc/general/head.html', '<%= copy.options.buildFolder %>/inc/general/foot.html', '<%= copy.options.buildFolder %>/inc/module/print.html']
    },
    concat: {
        options: {
            separator: ''
        },

        // JS build starts here
        mainJS: {
            src : readJSFile(grunt.file.readJSON('buildFiles/mainjs.json'), 'assets/js/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/<%= pkg.name %>.min.js'
        },
        libheaderJS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/headerjs.json'), 'assets/js/libs/headerJS/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/libs/headerJS/ladbrokes.lib.top.js'
        },
        libbetdaqJS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/betdaqjs.json'), 'assets/js/libs/betdaqJS/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/libs/betdaqJS/ladbrokes.betdaq.js'
        },
        commonJS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/common.json'), 'assets/js/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/common.min.js'
        },
        racingJS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/racing.json'), 'assets/js/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/racing.min.js'
        },
        landingJS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/landing.json'), 'assets/js/'),
            dest: '<%= copy.options.buildFolder %>/assets/js/landing.min.js'
        },
        // ladbrokes.min.css starts here
        mainCSS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/maincss.json'), 'assets/css/'),
            dest : '<%= copy.options.buildFolder %>/assets/css/ladbrokes.min.css'
        },
        globalCSS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/globalcss.json'), 'assets/css/'),
            dest : '<%= copy.options.buildFolder %>/assets/css/global.min.css'
        },
        responsiveCSS: {
            src: readJSFile(grunt.file.readJSON('buildFiles/responsivecss.json'), 'assets/css/'),
            dest : '<%= copy.options.buildFolder %>/assets/css/ladbrokes.responsive.css'
        }
    },
    uglify: {
        options: {
           // dont make comma separted all the statements so that it can be debug on live env.
            compress :{
                sequences : false
            },
            banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> <%= grunt.template.today("HH-MM-ss") %> */\n'
        },
        mainJS: {
            files: {
              '<%= copy.options.buildFolder %>/assets/js/<%= pkg.name %>.min.js': ['<%= concat.mainJS.dest %>']
            }
        },
        libheaderJS: {
            files: {
              '<%= copy.options.buildFolder %>/assets/js/libs/headerJS/ladbrokes.lib.top.js': ['<%= concat.libheaderJS.dest %>']
            }
        },
        libbetdaqJS: {
            files: {
                '<%= copy.options.buildFolder %>/assets/js/libs/betdaqJS/ladbrokes.betdaq.js': ['<%= concat.libbetdaqJS.dest %>']
            }
        },
        commonJS: {
            files: {
                '<%= copy.options.buildFolder %>/assets/js/common.min.js': ['<%= concat.commonJS.dest %>']
            }
        },
        racingJS: {
             files: {
                '<%= copy.options.buildFolder %>/assets/js/racing.min.js': ['<%= concat.racingJS.dest %>']
            }
        },
        landingJS: {
            files: {
                '<%= copy.options.buildFolder %>/assets/js/landing.min.js': ['<%= concat.landingJS.dest %>']
            }
        },
        configJS: {
            files: {
              '<%= copy.options.buildFolder %>/assets/js/ladbrokes.config.prod.min.js': ['<%= copy.options.buildFolder %>/assets/js/ladbrokes.config.prod.js']
            }
        }
    },
     // CSS build starts here
    cssmin: {
        my_target: {
           src: '<%= copy.options.buildFolder %>/assets/css/ladbrokes.min.css',
           dest : '<%= copy.options.buildFolder %>/assets/css/ladbrokes.min.css'
        },
        globalCSS: {
          src : '<%= copy.options.buildFolder %>/assets/css/global.min.css',
          dest : '<%= copy.options.buildFolder %>/assets/css/global.min.css'
        },
        printCSS: {
          src: '<%= copy.options.buildFolder %>/assets/css/print.css',
          dest: '<%= copy.options.buildFolder %>/assets/css/print.min.css'
        },
        racingCSS: {
          src: '<%= copy.options.buildFolder %>/assets/css/racing.css',
          dest: '<%= copy.options.buildFolder %>/assets/css/racing.min.css'
        },
        landingCSS: {
          src: '<%= copy.options.buildFolder %>/assets/css/landing.css',
          dest: '<%= copy.options.buildFolder %>/assets/css/landing.min.css'
        },
        responsiveCSS:{
          src: '<%= copy.options.buildFolder %>/assets/css/ladbrokes.responsive.css',
          dest: '<%= copy.options.buildFolder %>/assets/css/ladbrokes.responsive.min.css'  
        }

    },

    clean: {
        options: {
            force: true
        },
        src0: '<%= concat.mainJS.src %>',
        src1: '<%= concat.libheaderJS.src %>',
        src3: '<%= concat.mainCSS.src %>',
        src4: '<%= concat.globalCSS.src %>',
        src5: [
            '<%= copy.options.buildFolder %>/script',
            '<%= copy.options.buildFolder %>/buildFiles',
            '<%= copy.options.buildFolder %>/node_modules',
            '<%= copy.options.buildFolder %>/Gruntfile.js',
            '<%= copy.options.buildFolder %>/package.json',
            '<%= copy.options.buildFolder %>/assets/js/libs/headerJS/jquery.min.js',
            '<%= copy.options.buildFolder %>/assets/js/ladbrokes.config.dev.js',
            '<%= copy.options.buildFolder %>/assets/js/libs/footerJS/mtagconfig.js', 
            '<%= copy.options.buildFolder %>/assets/js/libs/footerJS/plugins.js',
            '<%= copy.options.buildFolder %>/assets/js/ladbrokes.beta.js', 
            '<%= copy.options.buildFolder %>/assets/js/ladbrokes.config.prod.js',
            '<%= copy.options.buildFolder %>/assets/js/respond.js',
            '<%= copy.options.buildFolder %>/assets/css/global.css', 
            '<%= copy.options.buildFolder %>/assets/css/print.css', 
            '<%= copy.options.buildFolder %>/assets/css/beta-site.css', 
            '<%= copy.options.buildFolder %>/assets/css/betslip.css', 
            '<%= copy.options.buildFolder %>/assets/css/mediaelementplayer.min.css',
            '<%= copy.options.buildFolder %>/assets/css/landing.css',
            '<%= copy.options.buildFolder %>/assets/css/minigames.css',
            '<%= copy.options.buildFolder %>/assets/css/nownextpool.css',
            '<%= copy.options.buildFolder %>/assets/css/racing.css',
            '<%= copy.options.buildFolder %>/assets/css/toteslip.css',
            '<%= copy.options.buildFolder %>/assets/css/*.scss',
            '<%= copy.options.buildFolder %>/assets/css/ladbrokes.responsive.css',
            '<%= copy.options.buildFolder %>/assets/css/generic-responsive.css',
            '<%= copy.options.buildFolder %>/assets/css/higher-resolution.css',
            '<%= copy.options.buildFolder %>/assets/css/ladbrokes-maxw-1200.css',
            '<%= copy.options.buildFolder %>/JSON-words.js'
        ],
        src6: readJSFile(grunt.file.readJSON('buildFiles/jsIgnore.json'), 'assets/js/'),
        src7: '<%= concat.libbetdaqJS.src %>',
    },


    shell: {
        add: {
           command: 'TortoiseProc.exe /command:commit /path:"<%= copy.options.buildFolder %>/"/logmsg:"Please verify this build before commit !" /closeonend:0'
        }
    },

    smushit: {
        path:{
            src:'<%= copy.options.buildFolder %>/assets/images'
        }
    }


});

grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-rename');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-smushit');

grunt.registerTask('default', [
    'exec', 
    'copy', 
    'concat', 
    'uglify', 
    'cssmin', 
    'useminPrepare', 
    'usemin', 
    'clean'/*, 'smushit'*/, 
    'shell'
    ]
);

};

4

2 に答える 2

4

Gruntfile を見てください。「min」という名前のタスクへの参照がある可能性があります。その参照を削除して、もう一度 grunt を実行してみてください。

より詳細な回答については、Gruntfile を質問に追加する必要があります。

編集: と呼ぶこともできますuglify。最後に次のような行を探します。

grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);

最後のオプションを削除します。一部のファイル パスを変更する必要がある場合もあります。

于 2013-11-07T12:36:51.823 に答える