mini-css-extract-plugin can not extract node_module css file
See original GitHub issue- Operating System: win7
- Node Version: v10.12.0
- NPM Version: 6.4.1
- webpack Version: 4.29.6
- mini-css-extract-plugin Version: 0.6.0
Below could build all of my scss files and css files into several stylesheet injections into the html file:
{
test: /\.(scss|css)$/,
use: [
// MiniCssExtractPlugin.loader,
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
]
}
Below cound only build one css file but without the node_module css file
{
test: /\.(scss|css)$/,
use: [
MiniCssExtractPlugin.loader,
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
]
}
But with “extract-text-webpack-plugin”: “^4.0.0-beta.0” everything behaves as expected. So, i wonder if there is a bug about extracting css file from node_modules?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top Results From Across the Web
mini-css-extract-plugin - npm
extracts CSS into separate files. ... Start using mini-css-extract-plugin in your project by running `npm i mini-css-extract-plugin`.
Read more >MiniCssExtractPlugin - webpack
If false, the plugin will extract the CSS but will not emit the file. It is often useful to disable this option for...
Read more >Webpack 4: How to extract CSS from Node module?
But adding LESS to my project only to extract styles from an external component seems not right to me. Is there a better...
Read more >Search - appsloveworld
[Solved]-Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ReferenceError: document is not defined-Reactjs.
Read more >error: cannot find module 'css-minimizer-webpack-plugin'
First, install the plugin. npm install mini-css-extract-plugin --save-dev.
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 Free
Top 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
This was the same issue for me as @baremetalfreak mentioned. I changed:
"sideEffects": false,
->"sideEffects": true,
and CSS was correctly emitted.
My issue was that I imported all of my CSS in App.js,
import CssTheme from './theme'
, but never did anything with the imported variable so it was assumed to be unused. I was able to verify that this was the case by justconsole.log(CssTheme)
while I still had"sideEffects": false,
in mypackage.json
Answer https://github.com/webpack-contrib/mini-css-extract-plugin/issues/386#issuecomment-489184730
You can mark only css as side effect using this
"sideEffects": ["*.css"],
inpackage.json