3
// webpack.config.js
const ImageminPlugin = require('imagemin-webpack-plugin').default


module.exports = {
  plugins: [
    new ImageminPlugin({
      pngquant: {
        quality: '50' // unreasonably low value to see it works
      }
    })
  ]
}
// angular.json
"architect": {
  "build": {
    "builder": "@angular-builders/custom-webpack:browser",
    "options": {
      "customWebpackConfig": {
        "path": "./webpack.config.js"
      },
    }
  },
  "serve": {
    "builder": "@angular-builders/custom-webpack:dev-server",
    "options": {
      "customWebpackConfig": {
        "path": "./webpack.config.js"
      },
    }
  }
}

This works fine in development but when I run the application in production:

"start:prod": "angular-http-server --path dist/event-io -p $PORT",
"build:prod": "ng build --prod --stats-json",

the image has its original size even though the plugin is actually loaded.

Is there a problem with order?

Michal
  • 4,952
  • 8
  • 30
  • 63

0 Answers0