-
Notifications
You must be signed in to change notification settings - Fork 137
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
Module resolver: virtualize vendor.css #1805
Module resolver: virtualize vendor.css #1805
Conversation
With a bit of experimentation on a vanilla Vite app @BlueCutOfficial discovered that we can probably get away with properly virtualising a raw css file making use of We've been struggling to make sure that the content-type is correct in an embroider test, there are a few things to try out but we could also try a "post middleware" to edit the content type of css responses. https://vitejs.dev/guide/api-plugin.html#configureserver if adding a post middleware to edit the content type doesn't work then we could just implement a normal middleware to handle the virtual css response correctly. Then for build mode we would just use the emit file as we wanted to but couldn't because it doesn't work in dev mode. |
425215f
to
0c31ba0
Compare
44981c2
to
00e95a1
Compare
9d46807
to
90a8cad
Compare
expectFile('./index.html').matches( | ||
'data-original-filename="vendor.css">', | ||
'does not have data-original-filename vendor.css' | ||
'has data-original-filename vendor.css' |
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.
The compat-app-builder used to compute a boolean implicitStyles
and add the stylesheet only if true
. With this PR, we simplify this and add the stylesheet without condition.
…f vendor.css with the virtual entrypoint
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.
LGTM 🎉 💪
This PR replaces the
assets/vendor.css
file generated in the rewritten-app with an entrypoint returning a virtual CSS:The content that was previously written in
assets/vendor.css
is now generated by thevirtual-vendor-styles
's functions.How to test
On the main branch, to get an
/assets/vendor.css
endpoint in the rewritten app, the vite-app needs to include at least one V1 addon that exposes CSS. On the presentvirtual-vendor-style
branch, the entry point is always there, but the content will be empty if no V1 addon exposes CSS.The POC branch BlueCutOfficial:poc-virtual-vendor-style eases testing: it installs two classic addons providing CSS styles. You can also install them this way:
Once the vite-app has these dependencies, you can test what happens when there is a
vendor.css
.poc-virtual-vendor-style
branch:ember-tag-input
andember-simple-tree
vendor.css
should be returned as a CSS file containing the addons stylesdist/assets
, there should be a fingerprintedmain-*.css
containing the addons stylesdist/index.html