Klathmon / imagemin-webpack-plugin

Plugin to compress images with imagemin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why can't I use this plugin with create-react-app ?

kopax opened this issue · comments

I am using create-react-app and react-app-rewired, I want to optimize my images assets, this is how I configure the plugins within config-overrides.js:

    config.plugins = (config.plugins || []).concat([
      // Make sure that the plugin is after any plugins that add images
      new ImageminPlugin({
        disable: process.env.NODE_ENV !== 'production', // Disable during development
        plugins: [
          imageminGifsicle({
            optimizationLevel: 1,
          }),
          imageminJpegtran(),
          imageminPngquant(),
          imageminSvgo(),
        ]
      }),
    ]);

I have tried without installing all the plugin manually but I kept having nothing and it seems dependencies were not even installed.

After checking the generated configuration, this is what I have :

    {
      "options": {
        "disable": false,
        "maxConcurrency": 8,
        "imageminOptions": {
          "plugins": [
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null
          ]
        },
        "externalImages": {
          "context": ".",
          "sources": [],
          "destination": ".",
          "fileName": null
        },
        "cacheFolder": null
      }
    }

Why does it fail to work ?