-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
webpack.mf.config.js
68 lines (60 loc) · 1.85 KB
/
webpack.mf.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
/**
* This webpack config creates an innerloop experience on port 2345 with the help of module federation feature
*/
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const {
getResolveAlias,
resources: { createServeConfig },
} = require('@fluentui/scripts-webpack');
const { webpackMerge } = require('just-scripts');
// These shared are known vendor dependencies for the module federation plugin
const shared = {
react: { singleton: true },
'react-dom': { singleton: true },
};
// These rootComponents are part of the "public API" of the @fluentui/react module federated bundle
const rootComponents = fs
.readdirSync(path.join(__dirname, 'src'))
.filter(filename => filename[0].toUpperCase() === filename[0])
.map(filename => filename.replace(/\.tsx?/, ''));
const rootComponentsExposes = {};
for (const component of rootComponents) {
rootComponentsExposes[`./lib/${component}`] = `@fluentui/react/src/${component}`;
}
// TODO: fork-ts-checker-webpack-plugin needs to be taught about the resolve alias -> pathmapping in order for the type checking to work
process.env.SKIP_TYPECHECK = true;
const mfConfig = {
output: {},
entry: './empty-entrypoint.js',
mode: 'development',
devtool: 'cheap-module-source-map',
optimization: {
concatenateModules: false,
},
module: {
rules: [],
},
plugins: [
new webpack.container.ModuleFederationPlugin({
name: 'fluentuiReact',
filename: 'remoteEntry.js',
exposes: {
...rootComponentsExposes,
'.': '@fluentui/react/src/index',
'./lib/index': '@fluentui/react/src/index',
},
shared,
}),
],
resolve: {
alias: getResolveAlias(),
},
devServer: {
port: 2345,
static: './dist',
},
};
const metaConfig = webpackMerge.merge(createServeConfig(), mfConfig);
module.exports = metaConfig;