2023-10-25 22:32:15 +02:00
|
|
|
const webpack = require("webpack");
|
|
|
|
const webpackMerge = require("webpack-merge");
|
2022-07-09 10:37:19 +02:00
|
|
|
const path = require("path");
|
2023-10-25 22:32:15 +02:00
|
|
|
const moment = require("dayjs");
|
|
|
|
const VERSION = require("../version.js");
|
2022-11-01 08:07:25 +01:00
|
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
2022-07-09 10:37:19 +02:00
|
|
|
|
2023-10-25 22:32:15 +02:00
|
|
|
function makeBuildStr() {
|
|
|
|
let buildStr = moment().format("YYYYMMDD-HHmmss");
|
|
|
|
// console.log("waveterm:electron " + VERSION + " build " + buildStr);
|
|
|
|
return buildStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const BUILD = makeBuildStr();
|
|
|
|
|
|
|
|
var electronCommon = {
|
2022-07-09 10:37:19 +02:00
|
|
|
entry: {
|
2023-10-05 20:25:32 +02:00
|
|
|
emain: ["./src/electron/emain.ts"],
|
2022-07-09 10:37:19 +02:00
|
|
|
},
|
|
|
|
target: "electron-main",
|
|
|
|
externals: {
|
2023-08-22 06:37:04 +02:00
|
|
|
fs: "require('fs')",
|
2022-07-09 10:37:19 +02:00
|
|
|
"fs-ext": "require('fs-ext')",
|
|
|
|
},
|
2023-10-25 22:32:15 +02:00
|
|
|
devtool: "source-map",
|
2022-07-09 10:37:19 +02:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
// exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: "babel-loader",
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
"@babel/preset-env",
|
|
|
|
{
|
2023-08-22 06:37:04 +02:00
|
|
|
targets:
|
|
|
|
"defaults and not ie > 0 and not op_mini all and not op_mob > 0 and not kaios > 0 and not and_qq > 0 and not and_uc > 0 and not baidu > 0",
|
2022-07-09 10:37:19 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
"@babel/preset-react",
|
2023-08-22 06:37:04 +02:00
|
|
|
"@babel/preset-typescript",
|
|
|
|
],
|
2022-07-09 10:37:19 +02:00
|
|
|
plugins: [
|
2023-08-22 06:37:04 +02:00
|
|
|
["@babel/transform-runtime", { regenerator: true }],
|
2022-07-09 10:37:19 +02:00
|
|
|
"@babel/plugin-transform-react-jsx",
|
2023-08-22 06:37:04 +02:00
|
|
|
["@babel/plugin-proposal-decorators", { legacy: true }],
|
|
|
|
["@babel/plugin-proposal-class-properties", { loose: true }],
|
|
|
|
["@babel/plugin-proposal-private-methods", { loose: true }],
|
|
|
|
["@babel/plugin-proposal-private-property-in-object", { loose: true }],
|
2022-07-09 10:37:19 +02:00
|
|
|
"babel-plugin-jsx-control-statements",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-22 06:37:04 +02:00
|
|
|
],
|
2022-07-09 10:37:19 +02:00
|
|
|
},
|
2023-10-25 22:32:15 +02:00
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".tsx", ".js"],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var electronDev = webpackMerge.merge(electronCommon, {
|
|
|
|
mode: "development",
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, "../dist-dev"),
|
|
|
|
filename: "[name].js",
|
|
|
|
},
|
2022-11-01 08:07:25 +01:00
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
2023-10-05 20:25:32 +02:00
|
|
|
patterns: [{ from: "src/electron/preload.js", to: "preload.js" }],
|
2022-11-01 08:07:25 +01:00
|
|
|
}),
|
2023-10-25 22:32:15 +02:00
|
|
|
new webpack.DefinePlugin({
|
2023-11-01 09:26:19 +01:00
|
|
|
__WAVETERM_DEV__: "true",
|
|
|
|
__WAVETERM_VERSION__: JSON.stringify(VERSION),
|
|
|
|
__WAVETERM_BUILD__: JSON.stringify("devbuild"),
|
2023-10-25 22:32:15 +02:00
|
|
|
}),
|
2022-11-01 08:07:25 +01:00
|
|
|
],
|
2023-10-25 22:32:15 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
var electronProd = webpackMerge.merge(electronCommon, {
|
|
|
|
mode: "production",
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, "../dist"),
|
|
|
|
filename: "[name].js",
|
2022-07-09 10:37:19 +02:00
|
|
|
},
|
2023-10-25 22:32:15 +02:00
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [{ from: "src/electron/preload.js", to: "preload.js" }],
|
|
|
|
}),
|
|
|
|
new webpack.DefinePlugin({
|
2023-11-01 09:26:19 +01:00
|
|
|
__WAVETERM_DEV__: "false",
|
|
|
|
__WAVETERM_VERSION__: JSON.stringify(VERSION),
|
|
|
|
__WAVETERM_BUILD__: JSON.stringify(BUILD),
|
2023-10-25 22:32:15 +02:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = {electronDev: electronDev, electronProd: electronProd};
|