【发布时间】:2015-01-14 11:40:38
【问题描述】:
我尝试使用grunt-template 模块创建config.jsfile,但它没有按预期创建任何文件。
我已经安装了 grunt-template npm install grunt-template --save-dev
当我运行grunt build 时,我希望创建一个配置文件,其中包含在模板配置中设置的正确内容。我在下面添加了 gruntfile、config.js.tpl 和 grunt build 结果。会有什么问题?
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
....
'template': {
'config': {
'options': {
'data': {
'backend': '127.0.0.1:8000'
}
}
},
'files': {
'config.js': ['config.js.tpl']
}
}
}
grunt.loadNpmTasks('grunt-template');
grunt.registerTask('build', [
'template'
]);
}
config.js.tpl
angular.module('report-constants',[])
.constant('env', {
'backend': ''
});
grunt 构建结果
执行时间(2015-01-14 11:33:59 UTC) 加载任务 4ms 44% 44% 模板:配置 3ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33% 模板:文件 1ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 11% 总共 9 毫秒
【问题讨论】:
标签: gruntjs