-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.prod.js
48 lines (39 loc) · 1.33 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
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const moment = require("dayjs");
const fs = require("fs");
const VERSION = "v0.3.4";
function makeBuildStr() {
let buildStr = moment().format("YYYYMMDD-HHmmss");
console.log("Hibiki " + VERSION + " build " + buildStr);
return buildStr;
}
const BUILD = makeBuildStr();
let BundleAnalyzerPlugin = null;
if (process.env.WEBPACK_ANALYZE) {
BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
}
let merged = merge.merge(common, {
mode: "production",
output: {
path: __dirname,
filename: "build/hibiki/latest/[name]-prod.min.js"
},
devtool: "source-map",
optimization: {
minimize: true,
},
});
merged.plugins.push(new LodashModuleReplacementPlugin());
merged.plugins.push(new MiniCssExtractPlugin({filename: "dist/[name].css", ignoreOrder: true}));
if (BundleAnalyzerPlugin != null) {
merged.plugins.push(new BundleAnalyzerPlugin());
}
merged.plugins.push(new webpack.DefinePlugin({
__HIBIKIVERSION__: JSON.stringify(VERSION),
__HIBIKIBUILD__: JSON.stringify(BUILD),
}));
module.exports = merged;