AngularMaterial和Kendo不适用于ModuleFederationPlugin:找不到Bootstrap调用。
创始人
2024-10-28 09:30:24
0

以下是一种解决方法。请注意,由于Angular Material和Kendo组件中存在任意数量的Bootstrap调用,因此此解决方法可能需要进行相应的调整。

1.在web components项目中安装webpack。可以使用以下命令:

npm install webpack --save-dev

2.将以下代码添加到“webpack.config.js”中:

const webpack = require('webpack'); const ModuleFederationPlugin = webpack.container.ModuleFederationPlugin; const nodeExternals = require('webpack-node-externals');

module.exports = { entry: './src/index.js', output: { filename: 'index.js', path: './dist', libraryTarget: 'commonjs2' }, target: 'node', externals: [nodeExternals()], plugins: [ new ModuleFederationPlugin({ name: 'your_project_name', library: { type: 'commonjs2' }, filename: 'remoteEntry.js', exposes: { './Module': './src/Module.js' }, shared: { '@angular/core': { requiredVersion: '11.3.0' }, '@angular/common': { requiredVersion: '11.3.0' }, '@angular/router': { requiredVersion: '11.3.0' }, ... } }), ] };

3.在Angular Material和Kendo依赖项中添加Bootstrap调用。例如,在“@angular/material”中,需要将以下代码添加到具有模块引用的文件:

import 'bootstrap/dist/css/bootstrap.min.css';

4.生成远程加载项并将其部署到远程服务器。

5.在主应用程序中,使用以下代码将远程加载项加载到Angular应用程序中:

import { loadRemoteEntry } from '@angular-architects/module-federation';

const url = 'http://your_remote_url/remoteEntry.js';

loadRemoteEntry(url, 'your_project_name') .then(() => import('remote_entry/Module')) .then(m => platformBrowserDynamic().bootstrapModule(m.Module

相关内容

热门资讯

wpk有伙牌吗!wpk俱乐部软... wpk有伙牌吗!wpk俱乐部软件,扑克世界牌局设置,AA德州教程(素来有挂);大神普及一款德州ai内...
黑科技能赢!(WepoKe)软... 黑科技能赢!(WepoKe)软件透明挂,(wePoke)一直真的有挂,揭秘攻略(有挂透视)是由北京得...
aapoker透明挂下载!德州... aapoker透明挂下载!德州wpk到底有没有外挂,wepoke挂透视,分享教程(固有存在有挂);小...
黑科技好友!(aaPoker)... 黑科技好友!(aaPoker)透明挂辅助app,(AAPOKer)好像有挂,玩家教你(有挂技巧)这是...
aapoker辅助软件!wep... aapoker辅助软件!wepoke有机器人吗,wepoke辅助透视教程,德州教程(本然有挂)1、点...
黑科技讲解!(wPK)透视辅助... 黑科技讲解!(wPK)透视辅助app,(wpK)一向是有挂,解说技巧(有挂方法);《WPK辅助透视》...
aapoker有挂吗!微扑克发... 1、aapoker有挂吗!微扑克发牌逻辑,wepoke游戏真的是有挂的,必备教程(都是是有挂)2、进...
黑科技app!(wEpOke)... 黑科技app!(wEpOke)软件透明挂,(wepOke)果然是真的有挂,玩家教程(有挂透视)准备好...
wepokeai代打的胜率!w... 1、wepokeai代打的胜率!wepoke人有挂吗,aa扑克网上的挂真的,科技教程(起初存在有挂)...
黑科技透明挂!(aaPOKER... 黑科技透明挂!(aaPOKER)透明挂辅助插件,(aapoKer)真是是真的有挂,力荐教程(有挂辅助...