我正在使用 ember.js,我们有一个要求,即我们必须仅在生产中而不是在开发中显示脚本标记(index.html 文件)。 有没有办法实现这个目标?
最佳答案
据我所知,修改index.html的最佳方法是在构建过程中使用repo插件。
生成插件
ember generate in-repo-addon prodction-scripts
然后在/lib/product-scripts/index.js
中添加:
contentFor: function (type, config) {
if (type === 'head' && config.environment === 'production') {
//inline this CSS so it is parsed the fastest
return `
<script></script>
`;
}
}
关于ember.js - 如何在ember.js中访问index.html中的ENV变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54572582/