gpt4 book ai didi

javascript - grunt-ng-constant 目标不能持续工作

转载 作者:数据小太阳 更新时间:2023-10-29 05:35:43 25 4
gpt4 key购买 nike

我在 grunt-ng-constant 中遇到了一个奇怪的问题,其中 3 个目标中只有 2 个有效。

我的配置如下所示:

grunt.initConfig({
ngconstant: {
options: {
space: ' ',
wrap: '"use strict";\n\n {%= __ngModule %}',
name: 'config'
},
// Environment targets
development: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'development',
apiEndpoint: 'http://your-development.api.endpoint:3000'
}
}
},
staging: {
options: {
dest: '<%= yeoman.app %>/scripts/config.js',
},
constants: {
ENV: {
name: 'staging',
apiEndpoint: 'http://your-staging.api.endpoint:3000'
}
}
},
production: {
options: {
dest: '<%= yeoman.dist %>/scripts/config.js',
},
constants: {
ENV: {
name: 'production',
apiEndpoint: 'http://api.livesite.com'
}
}
}
}
})

我有以下任务正在注册

 grunt.registerTask('development', [
'ngconstant:development'
]);

grunt.registerTask('staging', [
'ngconstant:staging'
]);

grunt.registerTask('production', [
'ngconstant:production'
]);

如果我运行以下两个命令,一切正常,并且生成了 config.js 文件,看起来很棒。

grunt development
grunt staging

但是运行 grunt production 不会生成 config.js 文件。我似乎无法弄清楚为什么会这样。

最佳答案

我同时开发和暂存您正在生成的任务 config.js<%= yeoman.app %> 开头的路径中的文件,但在生产中,您使用的是以 <%= yeoman.dist %> 开头的.

我会检查第二条路径(或 yeoman.dist)是否存在。

关于javascript - grunt-ng-constant 目标不能持续工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32449629/

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