From what I understand, extract-text-webpack-plugin bundles all the css files imported into your React components into a separate separate CSS file. Then a separate CSS file can be referenced in the HTML header to prevent FOUC (Flash Of Unstyled Content). Using extract-text-webpack-plugin counteracts some of the benefits of importing your CSS in your React js files, such as hot loading.
What is the difference between using extract-text-webpack-plugin and replacing all import stylesheets in your component files with one link to the combined CSS file in the header of the HTML template?
It doesn't matter if you use CSS modules or import your CSS?
UPDATE: added an example for clarification.
Scenario A:
- component1.css (imported into component1.js)
- component2.css (imported into component2.js)
- the attached CSS file generated by extract-text-webpack-plugin (called in the HTML header)
Scenario B:
- component1.css (not specified in js files)
- component2.css (not specified in js files)
- master CSS file combined using the SASS method, Laravel mix.style, etc. (called in the HTML header)
Why go with scenario A, not B?
source share