Skip to content

Commit

Permalink
docs: provide an example of adding a custom file loader configuration…
Browse files Browse the repository at this point in the history
… in webpack-chain
  • Loading branch information
xiaoxiao committed Mar 7, 2024
1 parent 0694d3a commit a7dff82
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion docs/docs/docs/api/plugin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ api.addHTMLHeadScripts(() => `console.log('I am in HTML-head')`)
通过 [webpack-chain](https://github.com/neutrinojs/webpack-chain) 的方式修改 webpack 配置。传入一个fn,该 fn 不需要返回值。它将接收两个参数:
- `memo` 对应 webpack-chain 的 config
- `args:{ webpack, env }` `arg.webpack` 是 webpack 实例, `args.env` 代表当前的运行环境。

e.g.
```ts
api.chainWebpack(( memo, { webpack, env}) => {
Expand All @@ -443,6 +442,18 @@ api.chainWebpack(( memo, { webpack, env}) => {
memo.plugins.delete('progess');
})
```
> 注意: 如果要添加自定义的文件类型相关loader请额外设置 type: "javascript/auto",否则会进入异常的loader处理链路。示例如下:
```
config.module
.rule('abc')
.test(/\.abc$/)
.type('javascript/auto') // 添加此行配置
.use('abc-loader')
.loader('abc-loader')
.end();
```


### modifyAppData (`umi@4` 新增)

Expand Down

0 comments on commit a7dff82

Please sign in to comment.