Search code examples
ember.jsember-cli

How can I include html with ember-cli only for a specific environment?


In my Brocfile.js I'm importing a script:

// Import script for development only
if (app.env === 'development') {
  app.import( app.bowerDirectory + '/some-script/some-script.js' );
};

That works just fine. But I also need to include a small init script in the html (which isn't really a vendor asset) which should not be included in a production build. How do I include some html only for a specific environment?


Solution

  • You can still check your config file from any file in your project:

    import config from '../path/to/config/environment';
    
    if(config.environment === "development") {
      someScript.init();
    }