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

相关内容

热门资讯

分享透视!拱趴大菠萝挂怎么安装... 分享透视!拱趴大菠萝挂怎么安装,微乐小程序辅助器,妙招教程(有挂讲解)-哔哩哔哩1、起透看视 拱趴大...
揭露透视!wepoker国外版... 揭露透视!wepoker国外版透视,微乐陕西小程序破解器下载,策略教程(有挂实锤)-哔哩哔哩1、实时...
分享透视!菠萝德州透视脚本,微... 分享透视!菠萝德州透视脚本,微乐小程序黑科技辅助工具推荐,方案教程(有挂教程)-哔哩哔哩1、菠萝德州...
辅助透视!大菠萝789辅助器下... 辅助透视!大菠萝789辅助器下载,微乐江苏自建房辅助app,演示教程(有挂讲解)-哔哩哔哩一、大菠萝...
解谜透视!fishpoker透... 解谜透视!fishpoker透视,微信小程序修改器,教程书教程(有挂方略)-哔哩哔哩1.fishpo...
解迷透视!wepoker科技辅... 解迷透视!wepoker科技辅助器,微乐麻辣自建房辅助视频,妙招教程(详细教程)-哔哩哔哩1、这是跨...
关于透视!wepoker作弊方... 关于透视!wepoker作弊方法,微乐房间辅助工具在哪下载,绝活教程(揭秘有挂)-哔哩哔哩所有人都在...
教你透视!拱趴大菠萝有挂吗,微... 教你透视!拱趴大菠萝有挂吗,微信小程序有挂吗辅助,手筋教程(有挂详情)-哔哩哔哩1、拱趴大菠萝有挂吗...
教你透视!wepoker到底有... 教你透视!wepoker到底有没有透视,微乐自建房脚本下载,机巧教程(有挂解惑)-哔哩哔哩1、进入游...
解谜透视!hhpoker有透视... 解谜透视!hhpoker有透视功能吗,微乐广西小程序开发,资料教程(有挂详细)-哔哩哔哩1、hhpo...