-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
35 lines (34 loc) · 1.41 KB
/
config-overrides.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const WorkboxWebpackPlugin = require('workbox-webpack-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
// Used to make the build reproducible between different machines (IPFS-related)
module.exports = (config, env) => {
if (env !== 'production') {
return config
}
const gitRevisionPlugin = new GitRevisionPlugin()
const shortCommitHash = gitRevisionPlugin.commithash().substring(0, 8)
config.output.filename = `static/js/[name].${shortCommitHash}.js`
config.output.chunkFilename = `static/js/[name].${shortCommitHash}.chunk.js`
config.plugins = config.plugins.filter(
(plugin) =>
!(
plugin instanceof WorkboxWebpackPlugin.GenerateSW ||
plugin instanceof ManifestPlugin ||
plugin instanceof MiniCssExtractPlugin
)
)
config.plugins.push(
new MiniCssExtractPlugin({
filename: `static/css/[name].${shortCommitHash}.css`,
chunkFilename: 'static/css/[name].chunk.css',
})
)
config.module.rules[1].oneOf.find((rule) => rule.loader === require.resolve('file-loader')).options.name =
'static/media/[name].[ext]'
config.module.rules[1].oneOf.find((rule) => rule.loader === require.resolve('url-loader')).options.name =
'static/media/[name].[ext]'
config.optimization.moduleIds = 'hashed'
return config
}