简体   繁体   English

如何在ember-cli-build.js中基于环境配置ember-cli-babel?

[英]how to configure ember-cli-babel based on environment in ember-cli-build.js?

We are migrating our site to ember, so as of now we use ember as well as JSPs. 我们正在将我们的站点迁移到ember,所以到目前为止我们使用的是ember和JSP。 Since in production, I have a polyfill loaded when my site loads, I want to use babel polyfill inside the ember app only on development and testing environment. 从生产开始,我在我的网站加载时加载了polyfill,我想在开发和测试环境中使用ember应用程序中的babel polyfill。 I do not want it on production bulid. 我不想把它放在生产上。 I know I can do the following 我知道我可以做到以下几点

//ember-cli-build.js
let app = new EmberApp(defaults, {
  'ember-cli-babel': {
    'includePolyfill': true 
  }
}

I need something like the following to include polyfill based on the environment. 我需要类似以下内容来包含基于环境的polyfill。

//ember-cli-build.js
let app = new EmberApp(defaults, {
  'ember-cli-babel': {
    'includePolyfill': this.ENV=='production' ? false:true 
  }
}

Pretty much what you said: 你刚才所说的话:

In my 2.18 app, 在我的2.18应用中,

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
    var mergeTrees = require('broccoli-merge-trees');
    var app = new EmberApp(defaults, {
       'ember-cli-babel': {
           'includePolyfill':EmberApp.env() !== 'production' 
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM