Closed tippillow closed 2 years ago
It means they have common modules in different chunks and webpack decide to duplicate it
@alexander-akait is it possible to make css shared chunk?
Yes, using splitChunks
or just put it in common file
@alexander-akait okay, thank you, will check https://webpack.js.org/plugins/split-chunks-plugin/
@alexander-akait thx, made shared chunk, duplication has gone, you are the best
@tippillow hi! i'm using CRA, react lazy, react-router and routes code splitting, have the same issue. could you help? what is your solution to make shared chunk?
@aliakseikulba hi! My CRA project was ejected, so i easily access webpack.config.file and add splitChunk option. Please read link above. If you don't want to eject your project, you can use https://github.com/timarney/react-app-rewired or it's alternatives.
I made branch add-shared-chunk in my project, where i created shared chunk, so you can look and try it. I hope I helped, let me know. Good luck!
Bug report
css styles of "shared" component duplicated when using css modules and react-lazy. It can broke styles in some scenarios
Actual Behavior
duplicated
Expected Behavior
not duplicated
How Do We Reproduce?
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationSystem: OS: macOS 10.15.7 Binaries: Node: 14.17.3 npm: 6.14.13 Browsers: Chrome: 93.0.4577.63 Safari: 13.1.3