-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
81 lines (77 loc) · 1.98 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
const TsConfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
// const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
// const HtmlWebpackPlugin = require("html-webpack-plugin");
const { TuneDtsPlugin } = require("@efox/emp-tune-dts-plugin");
const webpack = require("webpack");
const path = require("path");
const packageJson = require("./package.json");
const deps = packageJson.dependencies;
const createName = `${packageJson.name}-${packageJson.version}.d.ts`;
const createPath = "./dist/@types";
const Dotenv = require("dotenv-webpack");
require("dotenv").config();
module.exports = {
output: {
clean: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: "file-loader",
},
],
},
resolve: {
plugins: [new TsConfigPathsPlugin()],
extensions: [".ts", ".tsx", ".js"],
},
plugins: [
new ModuleFederationPlugin({
name: "core_components",
filename: "remoteEntry.js",
exposes: {},
remotes: {},
shared: {
react: {
singleton: true,
requiredVersion: deps.react,
},
"react-dom": {
singleton: true,
requiredVersion: deps["react-dom"],
},
"@material-ui/core": {
singleton: true,
},
"@material-ui/icons": {
singleton: true,
},
"@material-ui/lab": {
singleton: true,
},
"styled-components": {
singleton: true,
requiredVersion: deps["styled-components"],
},
},
}),
// new HtmlWebpackPlugin({
// template: "./public/index.html",
// }),
new webpack.ProvidePlugin({
process: "process/browser",
}),
new TuneDtsPlugin({
output: path.join(createPath, createName),
path: createPath,
name: createName,
isDefault: true,
}),
],
};