gpt4 book ai didi

javascript - 使用 Grunt 的 Dryer 文件路径

转载 作者:行者123 更新时间:2023-12-03 12:15:05 35 4
gpt4 key购买 nike

我正在向项目添加 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'
}
},

最佳答案

只需使用 <%= 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']
}
}
}
}

关于javascript - 使用 Grunt 的 Dryer 文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24757050/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com