PackageVersion: 0.4.2
Node: 9.3.0
Adding the following seems to work in development mode, but when switching to production mode it no longer emits the css files.
plugins: [new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css'
})],
module: {
rules: [{
test: /\.s?css/,
include: SRC_PATH,
use: [
MiniCssExtractPlugin.loader,
{loader: 'css-loader', options: {importLoaders: 2}},
'postcss-loader',
{loader: 'sass-loader', options: {includePaths: SASS_INCLUDES}}
]
}]
}
This configuration works find in development mode but not production
@MikaAK looks you have invalid configuration, please provide minimum reproducible test repo
https://github.com/Lure-Consulting/javascript-projects-starter/tree/svelte @evilebottnawi
Run webpack --mode development and webpack --mode production
@MikaAK the problem appears to be that the project sets an incorrect "sideEffects" configuration in its package.json - in that it says that anything but *.pug does not have side-effects and can be dropped as an optimization in production. Adding "*.scss" to "sideEffects" causes the CSS to be emitted.
See the caveats here:
https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free
So it does! Thanks @edmorley
Most helpful comment
@MikaAK the problem appears to be that the project sets an incorrect
"sideEffects"configuration in itspackage.json- in that it says that anything but*.pugdoes not have side-effects and can be dropped as an optimization in production. Adding"*.scss"to"sideEffects"causes the CSS to be emitted.See the caveats here:
https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free