Skip to content

Commit

Permalink
Merge branch 'master' into reduce-css-file-size
Browse files Browse the repository at this point in the history
  • Loading branch information
ghassanmas committed Jan 18, 2023
2 parents 450c6f1 + efdaf60 commit 45c2f79
Show file tree
Hide file tree
Showing 8 changed files with 1,870 additions and 4,921 deletions.
37 changes: 19 additions & 18 deletions config/webpack.dev-stage.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This is the dev Webpack config. All settings here should prefer a fast build
// time at the expense of creating larger, unoptimized bundles.
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');

const { merge } = require('webpack-merge');
const Dotenv = require('dotenv-webpack');
Expand Down Expand Up @@ -124,26 +125,26 @@ module.exports = merge(commonConfig, {
},
{
test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65,
},
gifsicle: {
interlaced: false,
},
pngquant: {
quality: [0.65, 0.90],
speed: 4,
},
loader: 'file-loader',
},
],
},
optimization: {
minimizer: [
'...',
new ImageMinimizerPlugin({
implementation: ImageMinimizerPlugin.sharpMinify,
options: {
encodeOptions: {
...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
{ ...accumulator, [value]: { progressive: true, quality: 65 } }
), {}),
gif: {
effort: 5,
},
},
],
},
},
}),
],
},
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
Expand Down
37 changes: 20 additions & 17 deletions config/webpack.dev.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This is the dev Webpack config. All settings here should prefer a fast build
// time at the expense of creating larger, unoptimized bundles.
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');

const { merge } = require('webpack-merge');
const Dotenv = require('dotenv-webpack');
Expand Down Expand Up @@ -125,26 +126,28 @@ module.exports = merge(commonConfig, {
},
{
test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65,
},
gifsicle: {
interlaced: false,
},
pngquant: {
quality: [0.65, 0.90],
speed: 4,
loader: 'file-loader',
},
],
},
optimization: {
minimizer: [
'...',
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.sharpMinify,
options: {
encodeOptions: {
...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
{ ...accumulator, [value]: { progressive: true, quality: 65 } }
), {}),
gif: {
effort: 5,
},
},
},
],
},
},
}),
],
},
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
Expand Down
40 changes: 21 additions & 19 deletions config/webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This is the prod Webpack config. All settings here should prefer smaller,
// optimized bundles at the expense of a longer build time.

const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');

const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { merge } = require('webpack-merge');
Expand Down Expand Up @@ -153,25 +155,7 @@ module.exports = merge(commonConfig, {
},
{
test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
use: [
'file-loader',
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 65,
},
gifsicle: {
interlaced: false,
},
pngquant: {
quality: [0.65, 0.90],
speed: 4,
},
},
},
],
loader: 'file-loader',
},
],
},
Expand All @@ -182,6 +166,24 @@ module.exports = merge(commonConfig, {
splitChunks: {
chunks: 'all',
},
minimizer: [
'...',
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.sharpMinify,
options: {
encodeOptions: {
...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
{ ...accumulator, [value]: { progressive: true, quality: 65 } }
), {}),
gif: {
effort: 5,
},
},
},
},
}),
],
},
// Specify additional processing or side-effects done on the Webpack output bundles as a whole.
plugins: [
Expand Down
38 changes: 8 additions & 30 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"react-dom": "^16.14.0"
},
"devDependencies": {
"react-test-renderer": "16.13.1"
"react-test-renderer": "16.14.0"
}
}
Loading

0 comments on commit 45c2f79

Please sign in to comment.