-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.prod.js
65 lines (57 loc) · 1.46 KB
/
webpack.prod.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-FileCopyrightText: 2022 Sveriges Television AB
//
// SPDX-License-Identifier: MIT
const path = require('path')
const crypto = require('crypto')
const common = require('./webpack.common')
const AssetMap = require('webpack-asset-map')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const hash = crypto
.createHash('md5')
.update(`${Date.now}${Math.random() * Math.pow(10, 10)}`)
.digest('hex')
const { merge } = require('webpack-merge')
const prod = {
mode: 'production',
plugins: [
new AssetMap({
path: './',
data: {
/*
Overwrite the default hash with out own
as that's what we are using for filenames
*/
hash,
/*
Statically declare which files should be
included in the application's html
These are passed through
the server to /app/template.js
*/
assets: [
`${hash}.shared.bundle.js`,
`${hash}.app.bundle.css`,
`${hash}.app.bundle.js`,
`${hash}.api.bundle.js`
]
}
}),
new MiniCssExtractPlugin({
filename: `${hash}.[name].bundle.css`
})
],
output: {
path: path.join(__dirname, '/dist'),
filename: `${hash}.[name].bundle.js`
}
}
module.exports = common.map(config => {
return merge(config, { ...prod })
})
/*
Allow all plugins to
be compiled in parallel
as they should not depend
on each other
*/
module.exports.parallelism = module.exports.length