2014-07-15 160 views
0

我加入咕嚕到一個項目,我使用的CONCAT任務創建幾個JS文件,但我想幹涸的文件路徑而不是重複靜態/ JS機文件路徑/ ...與咕嚕

concat: { 
libraries: { 
    src: ['static/js/jquery-ui-1.9.2.custom.min.js'], 
    dest: 'static/scripts/libraries.js' 
}, 
plugins: { 
    src: ['static/js/le-mtagconfig.js', 'static/js/jquery.magnific.js', 'static/js/jquery.tipTipTui.js', 'static/js/jquery.galleriffic.js', 'static/js/jquery.opacityrollover.js', 'static/js/jquery.bxslider.min.js' ], 
    dest: 'static/scripts/plugins.js' 
}, 
site_52: { 
    src: ['static/js/main.js', 'static/direct/js/main.js', 'static/js/52.js', 'static/direct/js/52.js' ], 
    dest: 'static/scripts/site_52.js' 
}, 
site_70: { 
    src: ['static/js/main.js', 'static/direct/js/main.js',, 'static/js/70.js', 'static/direct/js/70.js' ], 
    dest: 'static/scripts/site_70.js' 
}, 
site_71: { 
    src: ['static/js/main.js', 'static/direct/js/main.js', 'static/js/71.js', 'static/direct/js/71.js' ], 
    dest: 'static/scripts/site_71.js' 
}, 
site_78: { 
    src: ['static/js/main.js', 'static/direct/js/main.js', 'static/js/78.js', 'static/direct/js/78.js' ], 
    dest: 'static/scripts/site_78.js' 
}, 
site_79: { 
    src: ['static/js/main.js', 'static/direct/js/main.js', 'static/js/79.js', 'static/direct/js/79.js' ], 
    dest: 'static/scripts/site_79.js' 
}, 
site_81: { 
    src: ['static/js/main.js', 'static/direct/js/main.js', 'static/js/81.js', 'static/direct/js/81.js' ], 
    dest: 'static/scripts/site_81.js' 
}, 
custom: { 
    src: ['static/js/tripadvisor.js', 'static/js/tripadvisor-templates.js', 'static/js/handlebars-v1.3.0.js', 'static/js/handlebars-helpers.js', 'static/js/jquery.modals.js', 'static/js/jquery.bxslidertui.js' ], 
    dest: 'static/scripts/custom.js' 
} 
}, 

回答

1

只需使用樣式名稱<%= varName =>

例如:

module.exports = function (grunt) { 

    grunt.js = 'static/js/'; 
    grunt.directJs = 'static/direct/js/'; 

    concat: { 
    plugins: { 
     site_52: { 
     src: [<%= grunt.js %>main.js', <%= grunt.directJs %>main.js'] 
     } 
    } 
    } 
}