-
Notifications
You must be signed in to change notification settings - Fork 19
/
webpack.config.js
114 lines (104 loc) · 2.85 KB
/
webpack.config.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const path = require("path");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const webpack = require("webpack");
const packageJson = require("./package.json");
let externals = {};
for (let key in packageJson.dependencies) {
if (key === "moment") {
key = key + "/" + key;
}
externals[key] = true;
}
externals["electron"] = true;
const PATHS = {
api: path.join(__dirname, "api"),
build: path.join(__dirname, ""),
documentation: path.join(__dirname, "out"),
publicPath: ""
};
const date = new Date().toISOString().replace(/T/g, " ").replace(/Z/g, "");
const package = require("./package.json");
let banner = [];
banner.push(package.name);
banner.push(package.version);
banner.push(date);
banner.push(package.author);
banner = [banner.join(",")];
banner.push("");
banner.push("Copyright (C) 2017 Castlabs GmbH.");
banner.push("Licensed under the Apache License, Version 2.0 (the \"License\");");
banner.push("you may not use this file except in compliance with the License.");
banner.push("You may obtain a copy of the License at");
banner.push("http://www.apache.org/licenses/LICENSE-2.0");
banner.push("Unless required by applicable law or agreed to in writing, software");
banner.push("distributed under the License is distributed on an \"AS IS\" BASIS,");
banner.push("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
banner.push("See the License for the specific language governing permissions and");
banner.push("limitations under the License.");
banner = banner.join("\n");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
mode: "production",
target: "node",
entry: {
"index": [
"./api/index"
],
"downstream-electron-be": [
"./api/downstream-electron-be"
],
"downstream-electron-fe": [
"./api/downstream-electron-fe"
],
"downstream-electron-preload": [
"./api/downstream-electron-preload"
],
"startServer": [
"./api/server/startServer"
]
},
output: {
path: PATHS.build,
publicPath: PATHS.publicPath,
filename: "[name].js",
chunkFilename: "[id].chunk.js",
libraryTarget: "umd"
},
devtool: 'eval-source-map',
module: {
rules: [
{
test: /\.js$/,
include: PATHS.api,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
}
}
}
],
noParse: function (content) {
return /api\/index\.js/.test(content);
}
},
plugins: [
new CleanWebpackPlugin({
//cleanOnceBeforeBuildPatterns: [PATHS.build, PATHS.documentation],
cleanOnceBeforeBuildPatterns: [],
verbose: true,
dry: false
}),
new webpack.BannerPlugin({
banner: banner
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin(
)
],
},
externals: externals
};