Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 907be67

Browse files
authored
Merge pull request #288 from ftonato/chore-minify_medias
chore: Add webpack process to minify medias (images)
2 parents cab5074 + e887b77 commit 907be67

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

config/webpack/webpack.analyze.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
const merge = require('webpack-merge');
2-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
1+
const merge = require('webpack-merge')
2+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
33

44
const analyzeConfig = {
5-
plugins: [
6-
new BundleAnalyzerPlugin({ analyzerMode: 'static' })
7-
]
8-
};
5+
plugins: [new BundleAnalyzerPlugin({ analyzerMode: 'static' })]
6+
}
97

10-
const prodConfig = require('./webpack.prod.js');
8+
const prodConfig = require('./webpack.prod.js')
119

12-
module.exports = merge(prodConfig, analyzeConfig);
10+
module.exports = merge(prodConfig, analyzeConfig)

config/webpack/webpack.shared.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
const { copyFileSync, readFileSync } = require('fs')
21
const { dirname, join } = require('path')
32
const AppManifestWebpackPlugin = require('app-manifest-webpack-plugin')
43
const CleanWebpackPlugin = require('clean-webpack-plugin')
54
const CopyWebpackPlugin = require('copy-webpack-plugin')
65
const DefinePlugin = require('webpack/lib/DefinePlugin')
76
const EnvironmentPlugin = require('webpack/lib/EnvironmentPlugin')
8-
const EventHooksPlugin = require('event-hooks-webpack-plugin')
97
const HtmlWebpackPlugin = require('html-webpack-plugin')
108
const sass = require('sass')
119
const autoprefixer = require('autoprefixer')
1210
const mqpacker = require('css-mqpacker')
13-
const get = require('lodash.get')
14-
const { map } = require('@code.gov/cautious')
11+
const ImageminPlugin = require('imagemin-webpack-plugin').default
1512

1613
const rootDir = dirname(dirname(__dirname))
1714
const nodeModulesDir = join(rootDir, 'node_modules')
@@ -227,6 +224,7 @@ module.exports = {
227224
new EnvironmentPlugin(['CODE_GOV_API_BASE', 'CODE_GOV_API_KEY', 'CODE_GOV_TASKS_URL']),
228225
new CleanWebpackPlugin([OUTPUT_PATH], { root: rootDir }),
229226
new CopyWebpackPlugin(patterns),
227+
new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
230228
new HtmlWebpackPlugin({
231229
hash: true,
232230
template: 'index.html',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"event-hooks-webpack-plugin": "^2.1.1",
7575
"history": "^4.9.0",
7676
"html-webpack-plugin": "^3.2.0",
77+
"imagemin-webpack-plugin": "^2.4.2",
7778
"jsoneditor": "^6.0.0",
7879
"lodash.assign": "^4.2.0",
7980
"lodash.get": "^4.4.2",

0 commit comments

Comments
 (0)