-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Compiles in dev, fails in prod: TypeError: $ is not a function #471
Comments
Please create reproducible test repo, without this we can't help and issue will be closed, thanks |
Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks! |
I have the same error happening on this branch: https://github.com/timwright12/webpack-starter/tree/update-all-broken |
any solution? |
I have same problem when "module:@babel/preset-env" option useBuiltIns = "usage". |
so did you cope with this issue? |
same issue here,and "entry" replacement also works |
Same issue here, using "entry" also works. |
I found a solution to this problem! It happens when you use babel and transpile your Explanation Before mini-css can extract your CSS it is put into a js module by css-loader as a string. This javascript module will then be detected by babel any processed like any other javascript file. Since you guys use Solution Disallow This way...
See this stack-overflow issue: https://stackoverflow.com/questions/58489738/minicssextractplugin-error-on-entry-point-build |
This answer took me hours to find, but triggered just the right part to fix my issue. I was seeing a "$ is not defined" error, but only while my webpack was trying to build a CSS file. If I removed the CSS file everything worked. So for anyone else who is using Yarn2, don't be stupid like me. Don't forget to add your |
Expected Behavior
Compiles successfully
Actual Behavior
Crashes when using prod config. Dev works fine. Getting about a gazillion errors. It seems, for every .ts or .tsx files that imports a sass file. Error is always:
If I set prod and dev webpack config files to be identical, it suffices to set --mode=production when running webpack, to trigger the crash.
Here is one for of a very simple react component that imports _index.scss:
Code
Please see this gist for webpack.config.dev.js and webpack.config.prod.js: https://gist.github.com/emilmuller/22b8f05e1294126edb94662015c39f4c
How Do We Reproduce?
I am unable to publish my source code due to this being an enterprise application.
Debugging?
I would really like to try and debug this myself, but unsure how to. The stack traces don't make no sense as they refer to line numbers that do not exist. I'm assuming these line numbers occur after transpilation.
The text was updated successfully, but these errors were encountered: