waveterm/webpack.prod.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-08-22 06:37:04 +02:00
const webpack = require("webpack");
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
2022-06-08 02:25:35 +02:00
const moment = require("dayjs");
const path = require("path");
const VERSION = require("./version.js");
2022-06-08 02:25:35 +02:00
function makeBuildStr() {
let buildStr = moment().format("YYYYMMDD-HHmmss");
2022-12-27 04:17:24 +01:00
console.log("Prompt " + VERSION + " build " + buildStr);
2022-06-08 02:25:35 +02:00
return buildStr;
}
const BUILD = makeBuildStr();
let BundleAnalyzerPlugin = null;
if (process.env.WEBPACK_ANALYZE) {
2023-08-22 06:37:04 +02:00
BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
2022-06-08 02:25:35 +02:00
}
let merged = merge.merge(common, {
mode: "production",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
2022-06-08 02:25:35 +02:00
},
2023-02-24 08:27:05 +01:00
devtool: false,
2022-06-08 02:25:35 +02:00
optimization: {
minimize: true,
},
});
if (BundleAnalyzerPlugin != null) {
merged.plugins.push(new BundleAnalyzerPlugin());
}
2023-08-22 06:37:04 +02:00
merged.plugins.push(
new webpack.DefinePlugin({
__PROMPT_DEV__: "false",
__PROMPT_VERSION__: JSON.stringify(VERSION),
__PROMPT_BUILD__: JSON.stringify(BUILD),
})
);
2022-06-08 02:25:35 +02:00
module.exports = merged;