From a7dff8258e776ef49d981def47d5ca508c0d9cfd Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Thu, 7 Mar 2024 16:52:31 +0800 Subject: [PATCH 1/3] docs: provide an example of adding a custom file loader configuration in webpack-chain --- docs/docs/docs/api/plugin-api.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/docs/docs/api/plugin-api.md b/docs/docs/docs/api/plugin-api.md index 50607538a795..0cd3ba522862 100644 --- a/docs/docs/docs/api/plugin-api.md +++ b/docs/docs/docs/api/plugin-api.md @@ -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}) => { @@ -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` 新增) From 7f1a9026cc36b93c25e101f74708793aeeaa8f35 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Mon, 11 Mar 2024 15:43:55 +0800 Subject: [PATCH 2/3] Update docs/docs/docs/api/plugin-api.md Co-authored-by: Peach --- docs/docs/docs/api/plugin-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/docs/api/plugin-api.md b/docs/docs/docs/api/plugin-api.md index 0cd3ba522862..fa954dded9eb 100644 --- a/docs/docs/docs/api/plugin-api.md +++ b/docs/docs/docs/api/plugin-api.md @@ -442,7 +442,7 @@ api.chainWebpack(( memo, { webpack, env}) => { memo.plugins.delete('progess'); }) ``` -> 注意: 如果要添加自定义的文件类型相关loader请额外设置 type: "javascript/auto",否则会进入异常的loader处理链路。示例如下: +> 注意: 如果要添加自定义的文件类型相关 loader 请额外设置 `type: "javascript/auto"`,否则会命中兜底的 asset rule。示例如下: ``` config.module From ad9090625e3929064bc8cd850d69d19ed9d1c55a Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Mon, 11 Mar 2024 15:44:12 +0800 Subject: [PATCH 3/3] Update docs/docs/docs/api/plugin-api.md Co-authored-by: Peach --- docs/docs/docs/api/plugin-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/docs/api/plugin-api.md b/docs/docs/docs/api/plugin-api.md index fa954dded9eb..e0573d3c9f2f 100644 --- a/docs/docs/docs/api/plugin-api.md +++ b/docs/docs/docs/api/plugin-api.md @@ -444,7 +444,7 @@ api.chainWebpack(( memo, { webpack, env}) => { ``` > 注意: 如果要添加自定义的文件类型相关 loader 请额外设置 `type: "javascript/auto"`,否则会命中兜底的 asset rule。示例如下: -``` +```js config.module .rule('abc') .test(/\.abc$/)