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

v2.4.2 update #3

Open
kopax opened this issue Dec 26, 2020 · 1 comment
Open

v2.4.2 update #3

kopax opened this issue Dec 26, 2020 · 1 comment

Comments

@kopax
Copy link

kopax commented Dec 26, 2020

Hi, I am trying to configure imagemin-webpack-plugin through react-app-rewired without your plugin and I get:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.plugins[10] should be one of these:
   object { apply, … } | function
   -> Plugin of type object or instanceof Function
   Details:
    * configuration.plugins[10] should be an object.
      -> Plugin instance
    * configuration.plugins[10] should be an instance of function
      -> Function acting as plugin

When I add in my config-overrides.js:

const ImageminPlugin = require('imagemin-webpack-plugin').default

module.exports = {
  webpack: (config, env) => {
    config.plugins.push([
      // Make sure that the plugin is after any plugins that add images
      new ImageminPlugin({
        disable: process.env.NODE_ENV !== 'production', // Disable during development
        pngquant: {
          quality: '95-100'
        }
      }),
    ]);
  },
}

I am looking at your plugin but it seems to include the dependencies imagemin-webpack-plugin with an outdated version, is this still up to date?

If so, should we update the version here?

I tried to still install near the next version it and this is what I got:

├── imagemin-webpack-plugin@2.4.2 
└─┬ react-app-rewire-imagemin-plugin@1.0.1
  └── imagemin-webpack-plugin@1.6.1 

I believe since the new version is major, the 1.6.1 is used.

I do not have any logs that prouve that this plugin work while I type npm run build:

> export REACT_APP_ENV=${REACT_APP_ENV:-prod}; cp src/config/env/.env.${REACT_APP_ENV} .env.local; react-app-rewired build

Creating an optimized production build...
(node:404) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Compiled successfully.

File sizes after gzip:

  163.25 KB  build/static/js/2.92f2f819.chunk.js
  27.44 KB   build/static/js/main.4336c6a3.chunk.js
  24.52 KB   build/static/css/2.b3012d7c.chunk.css
  11.68 KB   build/static/css/main.ce99caf8.chunk.css
  2.22 KB    build/static/js/3.7e6c35ce.chunk.js
  1.18 KB    build/static/js/runtime-main.9ddf168b.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy

I tried within config-overrides.js to do writeFileSync('webpackconfig.json', JSON.stringify(config, null, 2), 'utf8');, and it seems that this configuration does not include anything related to the plugin...

Any clue on how to use it and ensure it's used? File size of media within that lib are equals...

Thanks for sharing!

@kopax
Copy link
Author

kopax commented Dec 28, 2020

I switched to [email protected] and now I can get a little compression for images.

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

1 participant