Open S-Masoud-Emamian opened 5 years ago
webpack.config.js
instead
pngquant: {quality: '65-90', speed: 4},
do this
pngquant: {quality: [0.65, 0.90], speed: 4},
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65
},
// optipng.enabled: false will disable optipng
optipng: {
enabled: false,
},
pngquant: {
quality: [0.65, 0.90],
speed: 4
},
gifsicle: {
interlaced: false,
},
// the webp option will enable WEBP
webp: {
quality: 75
}
}
},
],
}]
instead
pngquant: {quality: '65-90', speed: 4},
do thispngquant: {quality: [0.65, 0.90], speed: 4},
it's working. thx))
This is my current webpack.server.js
. As you can see, I have commented out the entire options
object for image-webpack-loader
.
{
test: /\.(jpg|png|gif)$/,
use: [
{
loader: "url-loader",
options: {
// Inline files smaller than 10 kB
limit: 10 * 1024,
},
},
{
loader: "image-webpack-loader",
// options: {
// mozjpeg: {
// enabled: false,
// // NOTE: mozjpeg is disabled as it causes errors in some Linux environments
// // Try enabling it i
// // Try enabling it in your environment by switching the config to:
// // enabled: true,
// // progressive: true,
// },
// gifsicle: {
// interlaced: false,
// },
// optipng: {
// optimizationLevel: 7,
// },
// pngquant: {
// quality: [0.65, 0.9],
// speed: 4,
// },
// },
},
],
},
But I am still seeing the same error message.
webpack:///./src/assets/images/play.png?:1 throw new Error("Module build failed (from ./node_modules/image-webpack-loader/index.js):\nArgumentError: Expected
options.qualityto be of type
arraybut received type
string\n at u (D:\\projectdirectory\\node_modules\\ow\\dist\\source\\index.js:1:12236)\n at D:\\projectdirectory\\node_modules\\imagemin-pngquant\\index.js:35:3\n
Can somebody help me look this up?
First the quality
was like "65-90"
, I changed it to [0.65,0.9]
and still the same error was being thrown.
So I commented the whole options
block but the output was the same.
I'm using reactjs. when I want to use png I got this error message: