-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
105 lines (99 loc) · 2.74 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
const { DefinePlugin } = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DotenvWebpackPlugin = require("dotenv-webpack");
const HtmlWebpackExternalsPlugin = require("html-webpack-externals-plugin");
const path = require("path");
require("dotenv").config();
const __ServiceConfig__ = JSON.stringify(require("./service.conf.json"));
const openempMf = JSON.stringify(require("./src/openemp.map.json"));
const vendors = JSON.stringify(require("./src/vendors.map.json"));
module.exports = (env) => {
const result = {
entry: path.resolve(__dirname, "src/root-config"),
output: {
filename: "openemp-root-config.js",
libraryTarget: "system",
path: path.resolve(__dirname, "dist"),
},
devtool: "source-map",
module: {
rules: [
{ parser: { system: false } },
{
test: /\.js$/,
exclude: /node_modules/,
use: [{ loader: "babel-loader" }],
},
],
},
devServer: {
historyApiFallback: true,
disableHostCheck: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
},
hot: true,
},
plugins: [
new DotenvWebpackPlugin(),
new DefinePlugin({
__ServiceConfig__,
}),
new HtmlWebpackPlugin({
inject: false,
template: "src/index.ejs",
templateParameters: {
isLocal: env && env.isLocal === "true",
openempMf,
vendors,
},
}),
new CleanWebpackPlugin(),
new HtmlWebpackExternalsPlugin({
externals: [
{
module: "systemjs",
entry: [
"dist/system.min.js",
"dist/extras/amd.js",
"dist/extras/named-exports.min.js",
],
},
{
module: "react",
entry: ["umd/react.development.js", "umd/react.production.min.js"],
},
{
module: "react-dom",
entry: [
"umd/react-dom.development.js",
"umd/react-dom.production.min.js",
],
},
{
module: "@reach/router",
entry: "umd/reach-router.min.js",
},
{
module: "single-spa",
entry: "lib/system/single-spa.min.js",
},
{
module: "regenerator-runtime",
entry: "runtime.js",
},
{
module: "axios",
entry: "dist/axios.min.js",
},
],
outputPath: "vendors",
enabled: true,
}),
],
externals: ["single-spa", /^@openemp\/.+$/],
};
return result;
};