Closed Angry-Sparrow closed 3 years ago
I configured it like this in webpack.config.js
{
test: /\.css$/i,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: (resourcePath, context) => {
`&{path.relative(path.dirname(resourcePath), context)}/`
},
modules: {auto: true}
}
},
resolve('css-loader'),
resolve('postcss-loader')
]
},
{
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader']
},
@leesgithub2019 ,
First of all thanks for creating this ticket, this helped my team debug a similar issue because you were able to isolate the issue to the sideEffects flag. Basically what is happening is webpack is tree shaking the styles from your bundle because you've declared in your package.json that there are no side effects. To fix you just need to changed "false" to "[".scss", ".css"]".
Hopefully that helps.
@leesgithub2019 ,
First of all thanks for creating this ticket, this helped my team debug a similar issue because you were able to isolate the issue to the sideEffects flag. Basically what is happening is webpack is tree shaking the styles from your bundle because you've declared in your package.json that there are no side effects. To fix you just need to changed "false" to "[".scss", ".css"]".
Hopefully that helps.
It helps, thanks. I'll learn more about why.
When I set
sideEffects: false
in package.json, the style is lost . In my project, I usescss
to implement my style.My package.json file configuration is as follows: