-
-
Notifications
You must be signed in to change notification settings - Fork 384
MiniCssExtractPlugin is incopatible with cross-package configurations #892
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
Comments
Duplicate #886, bug in webpack, already reported |
Shoot, sorry for bothering you then :) Wasnt aware of that issue, thanks |
@alexander-akait is it a duplicate, though? |
hm, I think I was wrong, |
So you have multiple |
on it |
subpackage sources: https://gist.github.com/Zackere/60549f09db9fd2bd36b4a150ee576dc7 the folder structure should look as follows:
Each subpackage compiles successfully on their own, but compiling together they crash |
Oh, and I discovered they clash even without parallelism enabled |
Yep, I see, you have multiple copied of |
Ill try it tomorrow, but it should suffice |
Ok, passing absolute path worked. I submitted a PR |
Fixed #894 |
Bug report
MiniCssExtractPlugin does not work in cross-package compilation setting
Context:
When configuring a monorepo for parallel compilation (https://webpack.js.org/configuration/configuration-types/#parallelism) I noticed that
MiniCssExtractPlugin
does not work when more than 1 configuration hasMiniCssExtractPlugin
as a plugin.I suggest, that
src/index.js:206
which now looks like this:webpack.util.serialization.register(CssModule, "mini-css-extract-plugin/dist/CssModule", null...
to be changed to something like this:
webpack.util.serialization.register(CssModule, "mini-css-extract-plugin/dist/CssModule", __dirname
or
webpack.util.serialization.register(CssModule, "mini-css-extract-plugin/dist/CssModule", Math.random()
1st one would prevent using the loader from the same
node_modules
twice and would enable using multipleMiniCssExtractPlugin
accross multiple configurations (which is what I want)2nd one would allow using
MiniCssExtractPlugin
multiple times without any restrictionsActual Behavior
Webpack throws an error:
Error: ObjectMiddleware.register: serializer for mini-css-extract-plugin/dist/CssModule/null is already registered
Expected Behavior
Webpack should be able to compile multiple configurations with
MiniCssExtractPlugin
as a pluginHow Do We Reproduce?
Set up two packages, which use
MiniCssExtractPlugin
. It is important, that webpack configurations have proper loader resolution:resolveLoader: { modules: [path.resolve(__dirname, 'node_modules'), 'node_modules'], }
Set up a third package, which as a webpack.config.js exports configurations of previous 2 packages.
Run webpack in the third package. It throws the error I described.
If we agree on a solution I'd more than happy to submit a PR
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: