forked from ManageIQ/manageiq-ui-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
57 lines (46 loc) · 1.63 KB
/
webpack.prod.js
File metadata and controls
57 lines (46 loc) · 1.63 KB
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
const webpack = require('webpack')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const config = require('./webpack.dev.js');
const manifest = require('./manifest.js');
// Source maps suitable for production use
config.devtool = 'cheap-module-source-map'
// minify
config.mode = 'production';
config.optimization.minimize = true;
config.plugins.push(
new webpack.NoEmitOnErrorsPlugin(),
// Cleans previous build
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [config.output.path],
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
}),
// Replace index.html with correct base href for production use
new HtmlWebpackPlugin({
base: '/ui/service/',
template: '../client/index.ejs',
chunks: ['app']
}),
// Write out dependent modules list for audit purposes
new StatsWriterPlugin({
filename: "webpack_modules_manifest.json",
fields: ["modules"],
transform(data) {
const modules = manifest.uniqueWebpackModules(data).map((path) => path.replace(/^\.\.\//, './'));
return JSON.stringify(modules, null, 2);
}
}),
// Write out dependent packages list for audit purposes
new StatsWriterPlugin({
filename: "webpack_packages_manifest.json",
fields: ["modules"],
transform(data) {
const modules = manifest.uniqueWebpackModules(data).map((path) => path.replace(/^\.\.\//, './'));
const packages = manifest.packagesFromModules(modules);
return JSON.stringify(packages, null, 2);
}
})
)
module.exports = config