Webpack CSS Minify

Hello,

Can someone explain me how to minify CSS with Webpack, this is my config:

const path = require('path');
module.exports = {
  entry: "./src/script.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, './assets/js')
  },
  module: {
    rules: [ {
      test: /\.css$/,
        use: [
            {loader :'css-loader', options: {minimize: true} }
        ]
    }]
  }
}

And it is not working.

I’m not sure if this is any help, but I’ve got something set up for using a Babel loader, which came from the Wes Bos ES6 course. The pattern looks slightly different to the way you have yours setup, but I’m not immediately sure if it’s directly transferable. Could be worth a look though.

module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015-native-modules']
        }
      }
    ]
  }

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.