Dom
Dom

Reputation: 404

how to access ENV variables in index.html in ember.js

I am using ember.js, there is a requirement for us where we have to show a script tag(index.html file) only in production and not in development. Is there a way to achieve this?

Upvotes: 2

Views: 689

Answers (1)

jrjohnson
jrjohnson

Reputation: 2459

The best way I know of to modify the index.html is during the build process using an in-repo addon.

Generate the addon with

ember generate in-repo-addon prodction-scripts

and then in /lib/production-scripts/index.js add:

contentFor: function (type, config) {
    if (type === 'head' && config.environment === 'production') {
      //inline this CSS so it is parsed the fastest
      return `
        <script></script>
      `;
    }
}

Upvotes: 2

Related Questions