Skip to content

Commit

Permalink
feat: add mfe config
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Oct 12, 2020
1 parent 6575fa7 commit b9658ac
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions bin/webpack/baseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,34 @@ const getBaseConfig = async () => {
// Ignore moment locale
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),

// 注册服务
new ModuleFederationPlugin({
name: APP_CONFIG.syscode,
// library: { type: 'var', name: APP_CONFIG.syscode },
remotes: {
layout: `layout@${APP_CONFIG.layout || '/'}system/layout/remoteEntry.js`,
},
filename: 'remoteEntry.js',
exposes: {
Routes: './src/routes',
'./bootstrap': './src/bootstrap',
},
shared: {
...deps,
react: {
eager: true,
singleton: true,
requiredVersion: deps.react,
// 注册微前端服务
APP_CONFIG.mfe &&
new ModuleFederationPlugin({
name: APP_CONFIG.syscode,
// library: { type: 'var', name: APP_CONFIG.syscode },
remotes: {
layout: `layout@${APP_CONFIG.layout || '/'}system/layout/remoteEntry.js`,
},
'react-dom': {
eager: true,
singleton: true,
requiredVersion: deps['react-dom'],
filename: 'remoteEntry.js',
exposes: {
Routes: './src/routes',
'./bootstrap': './src/bootstrap',
},
},
}),
],
shared: {
...deps,
react: {
eager: true,
singleton: true,
requiredVersion: deps.react,
},
'react-dom': {
eager: true,
singleton: true,
requiredVersion: deps['react-dom'],
},
},
}),
].filter(Boolean),
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.scss', '.css', '.mass'],
alias: {
Expand Down

0 comments on commit b9658ac

Please sign in to comment.