名称: webpack 描述: Webpack配置、模块联邦、加载器、插件和优化。 允许工具: 读取、写入、编辑、Bash、Glob、Grep
Webpack 技能
提供Webpack配置和优化的专家级协助。
能力
- 配置生产环境的webpack
- 设置模块联邦
- 创建自定义加载器/插件
- 优化打包体积
- 配置代码分割
配置示例
const { ModuleFederationPlugin } = require('webpack').container;
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
filename: '[name].[contenthash].js',
chunkFilename: '[name].[contenthash].chunk.js',
},
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
},
},
},
},
plugins: [
new ModuleFederationPlugin({
name: 'app',
remotes: { shared: 'shared@http://localhost:3001/remoteEntry.js' },
}),
],
};
目标流程
- 构建优化
- 微前端架构
- 遗留系统迁移