带有Grunt的烘干机文件路径

时间:2014-07-15 11:29:41

标签: javascript gruntjs grunt-contrib-concat

我正在为一个项目添加grunt,我正在使用CONCAT任务创建几个JS文件但是我想干掉文件路径而不是重复static / 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 个答案:

答案 0 :(得分: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']
      }
    }
  }
}