Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build-time configuration of index.html #845

Open
sandstrom opened this issue Aug 16, 2022 · 3 comments
Open

Build-time configuration of index.html #845

sandstrom opened this issue Aug 16, 2022 · 3 comments

Comments

@sandstrom
Copy link
Contributor

I'd like to gauge interest / comments for an easier way to customize index.html output.

Use-case

We have some dynamic values that we want to interpolate into the index.html file at build time. For example, static classes on the <html> element and special meta attributes.

Ember already provides the content-for hook, but adding individual attributes to specific html elements is trickier.

Possible solution

  • Exposing the internal configReplacePatterns API, for example a addReplacePattern method or a key under config (environment.js), say additionalReplacePatterns: [ … ]
  • Allowing custom 'slots' for use with {{content-for 'my-slot'}}.

Reference code

https://github.com/ember-cli/ember-cli/blob/b24b73b388934796ca915ca665b48a27c857199b/lib/utilities/ember-app-utils.js#L169

@jrjohnson
Copy link
Sponsor

It doesn't meet your needs here, but for discussion sake what we do is use ember-cli-deploy-json-config to extract our index.html into JSON and then parse that json on the server to send a final index.html with these dynamic parts added there.

@sandstrom
Copy link
Contributor Author

Thanks, good suggestions!

We also have a hack in place to make this work. But it would be cleaner if something like this was available in core. Customizing index.html is pretty common.

@bertdeblock
Copy link
Member

I assume, under Embroider (if it's possible / allowed at some point), that using https://github.com/jantimon/html-webpack-plugin might be an option to customise the final index.html?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants