我的问题如下;我正在使用 grunt-include-source ( https://www.npmjs.com/package/grunt-include-source ) 将我的脚本和 css 包含到我的 index.html 中,这工作正常,但我只能指定一个基本路径,我想为 dev 和 dev 设置此插件生产。 (我使用相同的文件夹结构,因此我的 index.html 中不会发生任何变化,唯一的区别是在我的作品中串联)
includeSource: {
options: {
basePath: 'dev'
},
myTarget: {
files: {
'dev/index.html': 'app/index.html'
}
}
},
上面的代码工作正常,现在我想要有 2 个不同的配置,但是在运行任务 includeSource:dev: 时这样的东西不起作用:
includeSource: {
dev: {
options: {
basePath: 'dev'
},
myTarget: {
files: {
'dev/index.html': 'app/index.html'
}
}
},
prod: {
options: {
basePath: 'prod'
},
myTarget: {
files: {
'prod/index.html': 'app/index.html'
}
}
}
},
index.html:
<!-- include: "type": "js", "files": "scripts/*.js" -->
有人可以帮助我如何实现这一目标吗?
编辑:为了更清楚一点,我在生产或开发构建完成后运行此脚本,对于我的产品/开发,所有脚本都存储在scripts/中
亲切的问候,
G
最佳答案
只需像这样配置您的任务即可:
includeSource: {
options: {
basePath: 'dev/'
},
dev: {
files: {
'dev/index.html': 'app/index.html'
}
},
prod: {
options: {
basePath: 'dist/'
},
files: {
'dist/index.html': 'app/index.html'
}
}
},
关于javascript - grunt-include-source 多个配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29676897/