2

I'm using image-webpack-loader but I got this error message:

I import my images like this:

import icon10 from '../../assets/img/icon10.png';

ERROR in ./app/assets/img/icon10.png
Module build failed (from ./node_modules/image-webpack-loader/index.js):
ArgumentError: Expected argument to be of type `array` but received type `string`
    at input (C:\Users\***\Desktop\pos\node_modules\imagemin-pngquant\index.js:32:3)
    at <anonymous>
 @ ./app/containers/Home/index.js 51:0-49 200:13-19
 @ ./app/containers/Home/Loadable.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js ./app/app.js
p7adams
  • 622
  • 1
  • 9
  • 24
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254

2 Answers2

1

Actually, I guess you should put your Webpack configuration for a better explanation. I believe your main issue is on your Webpack, based on the document you must set your loader like below:

rules: [
  {
    test: /\.(gif|png|jpe?g|svg)$/i,
    use: [
      'file-loader',
      {
        loader: 'image-webpack-loader'
      }
    ]
  }
];
0

Based on this GitHub issue, you probably need to change following settings in your webpack.config.js:

Instead of

pngquant: {
  quality: '65-90',
  speed: 4,
},

you need to use

pngquant: {
  quality: [0.65, 0.90],
  speed: 4,
},
adius
  • 13,685
  • 7
  • 45
  • 46