如何扩展我的自定义环境(和构建),例如,从生产
中“暂存”?
最终我想做ember build --environment=staging
,获得“生产”构建提供的好处和优化+想要提供一些自定义配置。
最佳答案
这比应有的情况更难做到,因此不建议这样做,因为我希望提供一些说明能够清楚地表明这一点。第一步是修改您的 config/environment.js
文件与您想要的任何定制。可能看起来像
if (environment === 'staging') {
//set something
}
但是你必须处理其他事情 production
自动带到餐 table 上。例如, Assets 指纹识别仅在生产中完成,因此您必须修改 emebr-cli-build.js
添加一些指令来制作 staging
喜欢 production
.
module.exports = function(defaults) {
const env = EmberApp.env() || 'development';
const isProductionLikeBuild = ['production', 'staging'].indexOf(env) > -1;
const app = new EmberApp(defaults, {
fingerprint: { enabled: isProductionLikeBuild },
sourcemaps: { enabled: isProductionLikeBuild },
minifyCSS: { enabled: isProductionLikeBuild },
minifyJS: { enabled: isProductionLikeBuild },
tests: env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,
可能还有更多的事情production
确实如此,但这些是我所知道的。
另一个值得一看的地方是 config/targets.js
您会在其中找到 const isProduction = process.env.EMBER_ENV === 'production';
行这也需要针对您的新环境进行更改。
关于javascript - 关于 Ember 中的自定义构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59272409/