-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
88 lines (71 loc) · 2.46 KB
/
webpack.common.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
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const webpack = require("webpack");
const ModuleFederationPlugin = webpack.container.ModuleFederationPlugin;
const path = require("path");
const deps = require("./package.json").dependencies;
const appSrcPath = path.resolve(__dirname, 'src');
module.exports = {
entry: "./src/index.tsx",
output: {
chunkFilename: '[name]-chunk.js?t=' + new Date().getTime() /* cache busting */,
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
plugins: [
new ModuleScopePlugin(appSrcPath),
].filter(Boolean),
},
module: {
rules: [{
oneOf: [
{
test: /\.tsx?$/,
exclude: [/node_modules/],
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/react", "@babel/env"],
}
},
{
loader: "ts-loader",
options: {
transpileOnly: true,
},
},
]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
loader: require.resolve("file-loader"),
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: "static/media/[name].[hash:8].[ext]",
}
},
]
}],
},
plugins: [
new CleanWebpackPlugin(),
new ModuleFederationPlugin({
name: "ic3",
shared: {
...deps,
// https://github.com/mui-org/material-ui/issues/21916
"@mui/private-theming": {singleton: true},
"@mui/material/styles": {singleton: true},
"@mui/styles": {singleton: true},
"@emotion/styled": {singleton: true},
"@emotion/core": {singleton: true},
"react": {singleton: true},
"react-dom": {singleton: true},
},
}),
].filter(Boolean),
};