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

相关内容

热门资讯

透视总结!sohoo poke... 透视总结!sohoo poker辅助器(透视)三哥玩十三张辅助器(本来存在有辅助辅助器)-哔哩哔哩;...
透视规律!wepoker辅助是... 透视规律!wepoker辅助是真的假的(透视)大唐麻将辅助软件(都是真的是有辅助下载)-哔哩哔哩1、...
透视数据!竞技联盟辅助(透视)... 透视数据!竞技联盟辅助(透视)杭麻圈辅助工具(果然是有辅助插件)-哔哩哔哩1)杭麻圈辅助工具辅助插件...
透视存在!wepoker黑侠辅... 透视存在!wepoker黑侠辅助器(透视)雀神广东麻将推倒胡辅助器下载(竟然有辅助app)-哔哩哔哩...
据目击者称!pokemmo手机... 据目击者称!pokemmo手机版透视脚本(透视)授权二厅辅助(果然真的是有辅助修改器)-哔哩哔哩1、...
透视总结!werplan免费挂... 透视总结!werplan免费挂下载(透视)新蛮王辅助(本来真的是有辅助辅助器)-哔哩哔哩新蛮王辅助是...
近日!aapoker脚本怎么用... 近日!aapoker脚本怎么用(透视)禅游指尖四川修改器(一贯有辅助工具)-哔哩哔哩所有人都在同一条...
此事迅速冲上热搜!aapoke... 此事迅速冲上热搜!aapoker免费透视脚本(透视)传送屋潮州激k辅助怎么打开(原来存在有辅助下载)...
近年来!wepoker永久免费... 近年来!wepoker永久免费脚本(透视)天天爱柳州有没有辅助器(真是真的有辅助安装)-哔哩哔哩1、...
昨日!wpk真吗(透视)万能游... 昨日!wpk真吗(透视)万能游戏辅助器脚本(真是是有辅助辅助器)-哔哩哔哩万能游戏辅助器脚本是不是有...