FIX: img-optimize-loader

Thank for the request.

Found 2 issues:
+ Images were converted to WebP by imagemin-webpack. Anyway it's excessive compression module so I have commented it out
+ Had to define name param for the img-optimize-loader to store images properly on build
This commit is contained in:
Tony Air 2020-08-04 21:17:45 +07:00 committed by GitHub
parent a14a94cbef
commit 5d006cb0f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,7 @@ const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack'); //const ImageminPlugin = require('imagemin-webpack');
//const ImageSpritePlugin = require('@a2nt/image-sprite-webpack-plugin'); //const ImageSpritePlugin = require('@a2nt/image-sprite-webpack-plugin');
const COMPRESS = true; const COMPRESS = true;
@ -81,7 +81,7 @@ let plugins = [
windows: true, windows: true,
}, },
}), }),
new ImageminPlugin({ /*new ImageminPlugin({
bail: false, // Ignore errors on corrupted images bail: false, // Ignore errors on corrupted images
cache: true, cache: true,
maxConcurrency: 3, maxConcurrency: 3,
@ -107,7 +107,7 @@ let plugins = [
['webp', { quality: 100 }], ['webp', { quality: 100 }],
], ],
}, },
}), }),*/
/*new ImageSpritePlugin({ /*new ImageSpritePlugin({
exclude: /exclude|original|default-|icons|sprite/, exclude: /exclude|original|default-|icons|sprite/,
commentOrigin: false, commentOrigin: false,
@ -278,6 +278,7 @@ module.exports = merge(common, {
test: /\.(png|webp|jpg|jpeg|gif|svg)$/, test: /\.(png|webp|jpg|jpeg|gif|svg)$/,
loader: 'img-optimize-loader', loader: 'img-optimize-loader',
options: { options: {
name: '[name].[ext]',
outputPath: 'img/', outputPath: 'img/',
publicPath: '../img/', publicPath: '../img/',
compress: { compress: {