-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
89 lines (82 loc) · 2.65 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
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const mf = require("@angular-architects/module-federation/webpack");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require("path");
const webpack = require("webpack");
const share = mf.share;
const sharedMappings = new mf.SharedMappings();
sharedMappings.register(
path.join(__dirname, 'tsconfig.json'),
[/* mapped paths to share */]);
module.exports = {
context: path.resolve(__dirname), // Sets the context to the directory where webpack.config.js is
output: {
uniqueName: "customModule",
publicPath: 'auto',
},
optimization: {
minimize: true,
runtimeChunk: false
},
resolve: {
alias: {
...sharedMappings.getAliases(),
}
},
experiments: {
outputModule: true
},
module: {
rules: [
// ... other rules ...
{
test: /\.(png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
},
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: 'src/assets', to: 'assets',
noErrorOnMissing: true,
globOptions: {
ignore: [
"**/.gitkeep", // Make sure this matches exactly the files you want to exclude
"**/.*" // This pattern excludes all hidden files
] } } // Adjust the paths as needed
]
}),
// DISABLE ngDevMode as it is not needed in a remoteEntry work around for issue: https://github.com/angular-architects/module-federation-plugin/issues/458
// new webpack.DefinePlugin({
// ngDevMode: "undefined",
// }),
// END DISABLE ngDevMode as it is not needed in a remoteEntry
new ModuleFederationPlugin({
library: { type: "module" },
// For remotes (please adjust)
name: "customModule",
filename: "remoteEntry.js",
exposes: {
'./custom-module': './src/bootstrap.ts',
},
// For hosts (please adjust)
// remotes: {
// "mfe1": "http://localhost:3000/remoteEntry.js",
// },
shared: share({
"@angular/core": { requiredVersion: "auto" },
"@angular/common": { requiredVersion: "auto" },
"@angular/router": { requiredVersion: "auto" },
"rxjs": { requiredVersion: "auto" },
"@angular/common/http": { requiredVersion: "auto" },
'@angular/platform-browser': { requiredVersion: 'auto' },
'@ngx-translate/core': { singleton: true},
'@angular/material': { singleton: true, requiredVersion: "auto" },
'@ngrx/store': { singleton: true},
...sharedMappings.getDescriptors()
})
}),
sharedMappings.getPlugin()
],
};