3.4.2 "sideEffects: false" option causes site to render improperly
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Version
3.4.2
Environment
webpack 4.6.0
Reproduction link
Steps to reproduce
With 3.4.2 I notice antd components CSS doesn’t load on my production site. If I edit node_modules/antd/package.json and remove the line “sideEffects: false” it goes back to normal.
My build makes use of babel-plugin-import, MiniCssExtractPlugin, less-loader to build the css
The development site with hot-reloading works fine, but when i build the production site it looks like no antd css loads at all
excerpt from webpack.prod.js
{
test: /\.(css|less)$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'less-loader',
options: {
modifyVars: antdTheme,
javascriptEnabled: true,
},
},
],
},
with 3.4.1 a “yarn build” will produce a vendors.js and vendors.css, but with 3.4.2 the vendors.css does not get generated at all
What is expected?
The production build worked in 3.4.1 and also works if i remove “sideEffects: false” from node_modules/antd/package.json
What is actually happening?
unknown
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
What Does Webpack 4 Expect From A Package With sideEffects
The "sideEffects": false flag in big-module's package.json indicates that the package's modules have no side effects (on evaluation) and only ...
Read more >INTRODUCTION - Maine.gov
2.31 “Medication Error” means the administration of any medication incorrectly, e.g., dosage, selection of drug, selection of consumer, time or method of ...
Read more >unittest — Unit testing framework — Python 3.11.1 ...
The class setting can be overridden in individual test methods by assigning an instance attribute, self.longMessage, to True or False before calling the...
Read more >Changelog — pytest documentation
issue #7807: Fixed regression in pytest 6.1.0 causing incorrect rootdir to be determined in some non-trivial cases where parent directories have config ...
Read more >Bison 3.8.1 - GNU.org
A GLR parser splitting inadvertently may cause problems less obvious than an LR parser statically choosing the wrong alternative in a conflict.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I modify
"sideEffects": false
and instead set it tothe problem goes away.
It might have to do with this from the Tree Shaking page on webpack.js.org:
“Note that any imported file is subject to tree shaking. This means if you use something like css-loader in your project and import a CSS file, it needs to be added to the side effect list so it will not be unintentionally dropped in production mode”
I see, so if you are using babel-import-plugin you’ll need to use this config
{ libraryName: 'antd', "libraryDirectory": "es", style: true }
.The default option of
lib
doesn’t work after this change.