-
Notifications
You must be signed in to change notification settings - Fork 513
[4.0.0-beta.0] emitting empty CSS files when using dynamic import #738
Comments
Getting same after enabling runtimeChunk. If the dynamic module (or even simple import to entry) has it's own styles - build creates:
And if I move styles to entry js (not imported module):
Looks like runtime.css has only imported styles from module, while main.css all other styles including runtime. |
The runtime css file surprised me as well, but an empty main.css is pretty much what I'd expect - if there were no styles emitted at that point. After all, one would include a in the HTML if you expect styles there. Not writing a main.css file would/could result in a 404. I guess the same logic applies to runtime.css? |
I wouldn't expect a file to be emitted at all. And no link added to the HTML, either (so no 404). That's how the previous version behaved, anyway. Why generate additional requests for empty files? |
I see your point ;-). Kinda appreciate the certainty still, that every entrypoint results in an output css file. If you don't want to use it, check if the file is empty and then don't put it in your html. |
I'm using |
Getting same problem, extract-text-webpack-plugin 4.0.0-beta.0 will extract empty runtime and vendor CSS. |
You can try mini-css-extract-plugin |
I'm sure mini will be great, but right now it's in its infancy and missing some key features like |
and also doesn't support HMR. |
There is a reproducible example: https://github.com/yangmingshan/react-demo/tree/next |
Using this as well may help with your problems: Just add |
TL;DR Use The |
It has the same question when use dynamic import. I can't put all the dynamic css in the chunk to one file. |
General:
When using dynamic
import()
code-splitting, ETWP creates an empty (0 byte) CSS file for the main entry point (e.g.main.css
) even if no CSS was imported. Additionally, if usingoptimization.splitChunks.chunks: "all"
to split initial chunks in addition to async, it creates an empty CSS file for vendors as well (e.g.vendors~main.css
) even if no vendor (node_modules
) CSS was imported. I'm assuming these two cases are the same root problem, I just don't know enough about how it works to know for sure.Real-world use case:
I include CSS from
node_modules
in my entry point, which gets split intovendors~main.css
as expected, but ETWP also creates an emptymain.css
when I don't have any local CSS imports.Reproduction repo:
https://github.com/wKovacs64/etwp-empty-files-demo
Versions:
extract-text-webpack-plugin: 4.0.0-beta.0
webpack: 4.0.1
The text was updated successfully, but these errors were encountered: