-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Webpack 4 Generates Empty CSS Vendors Bundle #6703
Comments
Thanks for your report. It would be great if you reduce your issue to a small reproducible example. Best put this example into a github repository together with instructions how to get to the problem. |
@sokra will do. I will update the issue once I put the repo together. Thanks |
I think this issue could be the problem. |
@sokra I added the repository here to replicate the issue https://github.com/l0gicgate/webpack-issue-6703 I tried to replicate the current setup I have and remove as many dependencies as possible that weren't necessary |
@sokra Question:How can I chunk without css?
but this code chunked a ‘commons.css’ file,I don’t want to chunk with css, how to do ? |
@sokra There is another reproducible example: https://github.com/yangmingshan/react-demo/tree/next |
@l0gicgate I just build your gist, but I get a |
Hm, I have downloaded this repo. npm install I can only see one |
@Legends I updated the repo. Please reinstall and run build again. You'll see empty |
@shinygang You have this configuration for vendor:
As I can see, you don't import any css/scss/... from within Or do you mean, why is there an empty Don't know, @sokra, @michael-ciniawsky ? |
@Legends it shouldn’t output empty css files. I just want a a vendor.js bundle. |
Yes, I agree, added sokra to take a look at it. |
Same issue for me:
produce vendors.js but also an empty vendors.css |
Tried https://github.com/KnisterPeter/html-webpack-exclude-empty-assets-plugin but with no luck... |
The issue happens also with webpack 4.5.0 |
The issue is not happening for me with a very minimal project with no dependencies at all. But when I add VueJs in my case (React in @l0gicgate case) the issue happens. Hope this will help to fix this issue. |
@ooflorent Can someone please take a look at this and explain what the issue is.. |
This currently breaks all "complex" builds. Forcing the config to be set to not have a vendor group defined. |
Using mini-css-extract-plugin solves the problem for me. But it has currently no HMR support. |
Same issue here - adding simple splitChunks from an example completely breaks css output - css file is empty (Im using ExtractTextPlugin as well) optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: "initial",
name: "vendor",
priority: 10,
enforce: true
}
}
}
}, |
Try to use the mini-css-extract-plugin as metnioned by @phiphou |
@Legends I can’t use that since sass-loader requires extract-text-webpack plugin. Why can’t this just be fixed? |
@l0gicgate |
@l0gicgate I would suggest, you ask this question in the "extract-text-webpack plugin" they will for sure give you an answer, about their plugin and webpack 4 support... For
|
Same config for me and you can implement HMR using this workaround : webpack-contrib/mini-css-extract-plugin#34 (comment) |
The problem is related to |
@l0gicgate I think you can close the issue, since an alternative solution has been given. You can though open a similar issue in |
@phiphou how is that a fix? The issue is also on this repo’s end. There’s even an option to ensure that bundles that have a size of zero shouldn’t even be output. I’m not closing this until it is resolved. |
@l0gicgate You are using |
@l0gicgate As @lili21 said, the issue is not related to Webpack but to There is nothing to fix here, but in the Create an issue there and close this one if you don't really want to use the new |
Thanks for the help here - I followed the instructions to use |
Okay, I was actually able to get back to 'normal' operation, i.e. splitting js files but ignoring css files by adding the following to webpack in cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/].*js/
}
} It simply tells Webpack to only split |
I have switched to mini-css-extract-plugin. Things broke even further trying to use extract-css-webpack-plugin when updating to Webpack 4.19.0. |
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
Empty CSS Vendors Bundle Being Generated
If the current behavior is a bug, please provide the steps to reproduce.
My config is outputting 2 bundles for both JS and CSS. I want to output one vendors.js and one bundle.js and once bundle.css file. Somehow it is creating an empty vendors.css file. I tried using removeEmptyChunks (which is enabled by default) but it doesn't do anything. It'll still emit an empty chunk:
Here is the config:
What is the expected behavior?
Generate 1 bundle for all CSS which is what was happening with the CommonsChunkPlugin and generate 2 bundles for JS, 1 cacheable vendor bundle and 1 commons bundle for everything else plus async route bundles.
If this is a feature request, what is motivation or use case for changing the behavior?
N/A
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Node 9.7.1, Webpack 4.1.1
The issue is replicated in this repository
https://github.com/l0gicgate/webpack-issue-6703
The text was updated successfully, but these errors were encountered: