Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't extract when in production mode #275

Closed
MikaAK opened this issue Sep 15, 2018 · 5 comments
Closed

Doesn't extract when in production mode #275

MikaAK opened this issue Sep 15, 2018 · 5 comments

Comments

@MikaAK
Copy link

MikaAK commented Sep 15, 2018

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

@alexander-akait
Copy link
Member

@MikaAK looks you have invalid configuration, please provide minimum reproducible test repo

@MikaAK
Copy link
Author

MikaAK commented Sep 15, 2018

https://github.com/Lure-Consulting/javascript-projects-starter/tree/svelte @evilebottnawi

Run webpack --mode development and webpack --mode production

@edmorley
Copy link

edmorley commented Oct 2, 2018

@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

@MikaAK
Copy link
Author

MikaAK commented Oct 2, 2018

So it does! Thanks @edmorley

@alexander-akait
Copy link
Member

Solved #275 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants