-
-
Notifications
You must be signed in to change notification settings - Fork 384
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 5 support #466
Comments
Duplicate webpack/webpack#9802 (comment) |
Hello @aaarichter, how did you fix this error? I received the same kind of error but it was for terser-webpack-plugin. |
@evilebottnawi What's the solution to this? |
Update mini-css-extract-plugin to the latest version |
terser-webpack-plugin supports only webpack@5, please read what is write your package manager |
@alexander-akait, @aaarichter , could you help me with the bug above please? |
I was having this same issue and it ended up being a capitalization issue with the file structure I was calling npm run watch from in the Terminal client in Visual Studio Code, so '/estimates/ instead of '/Estimates/' |
@raman-kazhadub Please create reproducible test repo |
The capitalisation issue mentioned by @stupidmonke was my problem too when running from Windows. My code lives in C:\Code\Personal... but I had done cd C:\code\Personal... and run |
Thanks @stupidmonke and @richardlawley C:\xampp\htdocs\plantilla\themes> npm run build produce error C:\xampp\htdocs\plantilla\Themes> npm run build |
@dhayzon Can you provide reproducible test repo? |
I can confirm this was also my problem. I originally called the folder I was able to fix it by moving the files inside my OS is Windows 10 Version 20H2 (OS Build 19042.685) |
windows fs is case-sensitive, so |
This isn't quite true. While filenames preserve case, allowing you to name something file.ext or File.ext, the underlying OS is not. This means that you cannot create file.ext and File.ext in the same location, and you can access file.ext as File.ext, FiLe.ExT and FILE.EXT without any problems. Similarly with directories, you can create C:\Code and access it as C:\code, C:\CODE and C:\cOdE. When you I did try to find the cause of this myself but don't know enough node. My guess is that something inside either this library or a dependency is using a case sensitive comparison for filenames rather than asking the OS to do it. |
Didn't I say the same thing? I don't understand what is the problem create simple reproducible test repo and I will say what is wrong |
Or please provide full stack of the error, I don't know even lines |
The stack trace had already been provided by someone else earlier on, but here you go...
Simple repro at https://github.com/richardlawley/mini-css-case-problem. Must be run from a powershell prompt:
If you run from a cmd prompt, or use the correct capitalisation when you cd, the project will build fine. |
@richardlawley strange, can reproduce, powershell versions:
|
Very very weird |
Is that a typo, you can reproduce or can't? If you can't reproduce, can you confirm your prompt includes the capitalisation you type in rather than what the directory was created as? e.g.
My version of powershell is slightly newer, but I doubt that's the cause
I've also checked node versions, I was running an old LTS (12.18.4) but I've updated to current LTS (14.15.3) and still have the problem. |
@richardlawley Do you have stats output? Can you provide? Very similar to what is used |
Yes |
@alexander-akait Sorry, not sure what stats output is (just starting with webpack). How do I get this? |
Example for v4, for v5 it will be different but also contains some information
|
Oh sorry. From working build...
From failed build:
|
@richardlawley Can you got to console.log(compilation);
// No need, already in code as you see
if (!(compilation instanceof Compilation)) {
throw new TypeError(
"The 'compilation' argument must be an instance of Compilation"
);
} |
Unfortunately due to nodejs/node#35730, trying to log compilation also crashes :( Just trying to go back to a version of node which doesn't have this problem. |
Perhaps a little bit of progress. Returned to 12.8.4.
I also tried some additional logging - I can also now reproduce the problem in vs code, but I'm not really any wiser as to why it happens or where to look. I suspect the problem is not something directly in this library, but further up the chain. |
hm, it should be not |
Can this be a kind of a bug in Node.js for Windows? @richardlawley, As a workaround for the original issue: new modern PowerShell 7 does not allow to |
@dthpth yes, looks like bug on Node.js side, because no problems on linux and windows, does somebody open an issue in Node.js? |
unfortunately, they said this is an "expected and documented behavior": nodejs/node#34597 (comment) |
bad, we should avoid using |
To be honestly I think it is powershell bug, because no problems on linux/macos/windows with cmd |
@richardlawley updating powershell is help? |
This is definitely a PowerShell bug. I upgraded to 7.1.0 and the error went away https://github.com/PowerShell/PowerShell/releases/tag/v7.1.0 |
Great, thanks for feedback |
I encountered the same issue on mac os x. Folder names were all correct case-wise. I had MiniCssExtractPlugin configured to use a filename pattern. Adding a chunkFilename helped in my case. My example is too complicated to post, and I don't have time to extract it from my project. |
I'm also having this issue though I think I'm trying something different than everyone else here. I originally was using the webpack-dev-server and that was compiling just fine. I wanted to still have my API work without starting another server so I switched to webpack-dev-middleware. Everything else compiles just fine except the CSS. I read through all the comments here and TLDR:
I opened compilation and logged it - same as person above:
If I print out compilation.constructor.name I get back the following: Compilation. Not sure how its not an instance of compilation when it seems to be. If I remove the instanceof check in JavascriptModulesPlugin.js I then get the same issue in NormalModule.js (in webpack lib). Removing the check there then says the css successfully was generated
That said, using the dev-middleware I don't actually see the css being inserted into my page like my compiled JS is. Not sure if that's a by product of bypassing the instanceof check or if MiniCssExtract doesn't play nice with dev-middleware's in memory files. If I run it with my production webpack config the CSS generates without errors so for me it seems to just be a compatibility issue with the webpack-dev-middleware module. I was having this issue originally with the html-webpack-plugin but their issues page said update to beta5 which I did and that fixed it. Not sure if what they did could be used to solve it in MiniCssExtract. Update
Weird enough... compilation instanceof Compilation also returns false, same as JavascriptModulesPlugin.js in webpacks lib. Curious why they even check that when it doesn't seem to be an instance of it anymore. |
@jrj2211 Can you open an issue in webpack with reproducible test repo? |
Sure thing, I'll work on making a simplified test repo tonight and create a bug report there. |
@alexander-akait & @jrj2211 any updates on this? Or any hints as to how to figure out what the problem is? I am running into the same issue:
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
}), I feel my issue is more related to linking as seen in #631 |
I haven't had time to continue looking at this but I did find a work around for my scenario. For me it builds fine in my production environment for some reason, but wasn't working with the webpack-dev-middleware server. I just made a dev config not use the mini css plugin and instead just the css-loader and style-loader. In my case, I realized there really wasn't a point to minify the css in dev. Sorry to not be more help. Looking at other modules that have since updated to webpack 5, they don't use the methods provided by webpack like this module does. Just to test it out, I removed the checks in the webpack code and everything compiled fine so that's the only thing holding this up for some of us. Since there was an issue on webpacks github talking about the instanceof issue (linked earlier) and it doesn't seem like any action will be taken on it, I think this module would have to have a change to not use their methods. |
very weird but resolved this by renaming project path to lowercased names |
Definitely the capitalization issue in the path 🤦 |
I would also like to add that if your folder structure has some special characters. For me my absolute path of my codebase was |
Feature Proposal
Webpack is currently in v5.0.0-beta7. Can mini-css-extract-plugin be made compatible?
Feature Use Case
Mini-css-extract-plugin is essential to extract css via webpack.
At the moment I'm seeing the following error:
The text was updated successfully, but these errors were encountered: