Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add webpack process to minify medias (images) #288

Merged
merged 1 commit into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions config/webpack/webpack.analyze.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const merge = require('webpack-merge');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const merge = require('webpack-merge')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')

const analyzeConfig = {
plugins: [
new BundleAnalyzerPlugin({ analyzerMode: 'static' })
]
};
plugins: [new BundleAnalyzerPlugin({ analyzerMode: 'static' })]
}

const prodConfig = require('./webpack.prod.js');
const prodConfig = require('./webpack.prod.js')

module.exports = merge(prodConfig, analyzeConfig);
module.exports = merge(prodConfig, analyzeConfig)
6 changes: 2 additions & 4 deletions config/webpack/webpack.shared.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
const { copyFileSync, readFileSync } = require('fs')
const { dirname, join } = require('path')
const AppManifestWebpackPlugin = require('app-manifest-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const DefinePlugin = require('webpack/lib/DefinePlugin')
const EnvironmentPlugin = require('webpack/lib/EnvironmentPlugin')
const EventHooksPlugin = require('event-hooks-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const sass = require('sass')
const autoprefixer = require('autoprefixer')
const mqpacker = require('css-mqpacker')
const get = require('lodash.get')
const { map } = require('@code.gov/cautious')
const ImageminPlugin = require('imagemin-webpack-plugin').default

const rootDir = dirname(dirname(__dirname))
const nodeModulesDir = join(rootDir, 'node_modules')
Expand Down Expand Up @@ -227,6 +224,7 @@ module.exports = {
new EnvironmentPlugin(['CODE_GOV_API_BASE', 'CODE_GOV_API_KEY', 'CODE_GOV_TASKS_URL']),
new CleanWebpackPlugin([OUTPUT_PATH], { root: rootDir }),
new CopyWebpackPlugin(patterns),
new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i }),
new HtmlWebpackPlugin({
hash: true,
template: 'index.html',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"event-hooks-webpack-plugin": "^2.1.1",
"history": "^4.9.0",
"html-webpack-plugin": "^3.2.0",
"imagemin-webpack-plugin": "^2.4.2",
"jsoneditor": "^6.0.0",
"lodash.assign": "^4.2.0",
"lodash.get": "^4.4.2",
Expand Down