-
Notifications
You must be signed in to change notification settings - Fork 142
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
Replace content-for using a Vite plugin #1836
Replace content-for using a Vite plugin #1836
Conversation
The canary-static-app error sounds a bit like the tests not being present but I am not sure how it's related to the PR and how it happens because the command The canary-vite-app-basics errors comes from a test using the command |
…r}} based on a content-for.json located in the .embroider folder
…t types that addons are expected to provide
…ary of content-types <-> html-snippet
…acement pattern on the index.html files so the vite plugin can take over
… the compat-app-builder that outputs it as a JSON
…e contentFor utility from ember-app-utils to generate the correct content for each type
…f the app templates
…or in case tests are built in dev or prod
…e new option availableContentForTypes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work 🎉
This PR moves
{{content-for}}
from stage 2 to stage 3:We no longer replace the
{{content-for}}
snippets in theindex.html
during the build of the rewritten app. Instead, we leave the{{content-for}}
in place and it's a new Vite plugin that performs the replacement. To do so, the Vite plugin relies on a new filecontent-for.json
output during the pre-build.Breaking change
The new approach supposes that Embroider knows in advance what types of
{{content-for}}
are provided by the addons, because the Broccoli plugin that builds the dictionary needs to be agnostic fromrewritten-app/index.html
if we don't want to be tied with stage 2.The new build option
availableContentForTypes
allows to extend the list of{{content-for}}
types in case an addon provides something custom. For instance, let's suppose your app relies on a classic addon that provides{{content-for "custom"}}
, you should add the following build option so the content can be replaced: