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

相关内容

热门资讯

透视免费!wepoker公共底... 透视免费!wepoker公共底牌(透视)都是真的是有挂(详细辅助揭秘攻略)1、不需要AI权限,帮助你...
透视ai!德普辅助器辅助器怎么... 透视ai!德普辅助器辅助器怎么用(透视)一贯真的是有挂(详细辅助细节揭秘)1)辅助挂:进一步探索辅助...
玩家必备科技!德州hhpoke... 玩家必备科技!德州hhpoker是真的吗,hhpoker万能辅助器,靠谱教程(有挂教程)是一款可以让...
透视了解!pokemmo手机版... 透视了解!pokemmo手机版脚本免费(透视)真是真的有挂(详细辅助解说技巧);1、用户打开应用后不...
一分钟揭秘!pokemmo手机... 1、一分钟揭秘!pokemmo手机版脚本免费,wepoker私人局辅助,wpk教程(有挂透视);详细...
透视辅助!wepoker辅助是... 透视辅助!wepoker辅助是真的假的(透视)真是是真的有挂(详细辅助黑科技教程)1、透视辅助!we...
透视数据!cloudpoker... 透视数据!cloudpoker怎么开挂(透视)切实是真的有挂(详细辅助技巧教程)1、操作简单,无需注...
盘点一款!hhpoker有没有... 1、盘点一款!hhpoker有没有作弊挂,pokerworld破解版下载,力荐教程(有挂技巧)。2、...
透视玄学!pokemmo辅助器... 透视玄学!pokemmo辅助器(透视)真是是真的有挂(详细辅助力荐教程)运辅助工具,进入游戏界面。进...
一分钟带你了解!德普之星辅助工... 一分钟带你了解!德普之星辅助工具如何打开,pokemmo手机版修改器,黑科技教程(有挂透视)准备好在...