Legacy plugin inlines CSS
See original GitHub issue⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.
- Read the docs.
- Use Vite >=2.0. (1.x is no longer supported)
- If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.
Describe the bug
When attaching @vitejs/plugin-legacy
, the index.css
content is inlined into the index-legacy.[hash].js
output file. This is reproducible with the base Preact template (and presumably others).
// index-legacy.[hash].js
var __vite_style__=document.createElement("style");__vite_style__.innerHTML="body,html{height:100%;width:100%;padding:0;margin:0;background:#fafafa;...",document.head.appendChild(__vite_style__) // ...`
truncated CSS for brevity
No changes/issues with the non-legacy output.
Reproduction
https://github.com/lukeed/bug-vite-legacy-inline-css
System Info
vite
version: 2.0.1- Operating System: Mac OS
- Node version: 14.15.5
- Package manager (npm/yarn/pnpm) and version: pnpm 5.11.1
Logs (Optional if provided reproduction)
Don’t see anything useful within --debug
output. Providing summary instead:
dist/assets/index-legacy.13201260.js 4.47kb / brotli: 1.82kb
dist/assets/vendor-legacy.14fe4df4.js 8.71kb / brotli: 3.26kb
dist/assets/polyfills-legacy.1b3a07f4.js 40.77kb / brotli: 14.08kb
dist/assets/favicon.17e50649.svg 1.49kb
dist/index.html 1.09kb
dist/assets/index.e8186b7a.css 0.35kb / brotli: 0.17kb
dist/assets/index.2844346d.js 4.51kb / brotli: 1.87kb
dist/assets/vendor.cc9d1722.js 8.64kb / brotli: 3.27kb
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:10 (1 by maintainers)
Top Results From Across the Web
CSS for [wpml_language_selector_widget] - WPML
I've located the class to be wpml-ls-statics-shortcode_actions and wpml-ls wpml-ls-legacy-list-horizontal. It seems the UL has the css I ...
Read more >Topic: CSS Overide and inline styles · BuddyPress.org
I see that when the plugin is permitted to load it's CSS inherently, the handle is bp-legacy-css, which of course allows for the...
Read more >Use styles and stylesheets | Block Editor Handbook
Method 1: Inline style. The first method shows adding the style inline. ... So in your plugin directory, create an editor.css file to...
Read more >critical css Plugin - Scully.io
Overview. Scully uses this plugin to inline the critical above the fold CSS into the HTML, and then lazy-load the CSS that is...
Read more >How to Eliminate Render-Blocking Resources on WordPress
Learn how to eliminate Render-Blocking JavaScript & CSS on your WordPress site either manually or using a plugin, like Autoptimize or WP ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would love an option to not have the CSS inlined in the legacy build since I’m integrating it in a backend-based project where I don’t have an
index.html
entrypoint to transform and thus enqueue the JS and CSS manually.I would be willing to look into this and make a PR adding that option. But so far, I even fail to see where this inlining is happening - it doesn’t seem to come from vite or vite-plugin-legacy (unless I missed it). So it seems so happen in one of the dependencies? Any hint would be welcome!
Update: Ok, just a few seconds after posting this, I stumbled upon #4448 - this seems related and I know where to look further now. However, I think a fix should be found that covers both the issues, using the legacy plugin or not.