ember-auto-import icon indicating copy to clipboard operation
ember-auto-import copied to clipboard

introduce `entrypointInjectables` to allow configuring webpack vars

Open fivetanley opened this issue 8 months ago • 1 comments

Allows configuring magic webpack vars like __webpack_nonce__ and __webpack_public_path__. These need to be set in each entry point file created by Ember CLI. Unfortunately, this can't be set in app.js or via app.import. Configuration of these vars is necessary for configuring Content Security Policy under certain scenarios or setting the hostname for a CDN that can only be known at runtime instead of build time.

Usage would look something like this in the ember-cli-build.js file:

autoImport: {
  entrypointInjectables: ['__webpack_public_path__ = window.__PUBLIC_PATH__;']
}

Then, in the index.html manipulated server side that sets that var before the ember-auto-import inject'd tags are loaded:

<script>
  window.__PUBLIC_PATH__ = 'https://mycdnaddress.com/';
</script>

Please see this comment for why this approach is necessary:

https://github.com/embroider-build/ember-auto-import/issues/409#issuecomment-2978074879

addresses https://github.com/embroider-build/ember-auto-import/issues/409

fivetanley avatar Jun 23 '25 22:06 fivetanley