Skip to content

Commit 0ef274a

Browse files
author
yushijie1
committed
docs: compile.include文档完善
1 parent e0304ad commit 0ef274a

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

docs/config-detail.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ module.exports = {
505505
:::info
506506
Taro v3.5 开始支持。
507507
508-
509508
Taro v4.0.0 开始支持 `vite` 值。
510509
:::
511510
@@ -531,7 +530,7 @@ Taro v4.0.0 开始支持 `vite` 值。
531530
532531
webpack 编译过程中的错误类型主要如下两类:1、致命的 wepback 错误(配置出错等)2、编译错误(缺失的 module,语法错误等)
533532
534-
0:表示发生“1、致命的webpack错误(配置出错等)”情况时,返回非 0 的退出码结束进程。
533+
0:表示发生“1、致命的 webpack 错误(配置出错等)”情况时,返回非 0 的退出码结束进程。
535534
1:表示发生“1、致命的 wepback 错误(配置出错等)2、编译错误(缺失的 module,语法错误等)”情况时,返回非 0 的退出码结束进程。
536535
537536
### compiler.prebundle
@@ -754,9 +753,27 @@ module.exports = {
754753
755754
`array`
756755
757-
配置额外**需要经过 Taro 编译的文件**,使用方式与 [mini.compile.exclude](./config-detail#minicompileexclude) 一致,同 [Rule.include](https://webpack.js.org/configuration/module/#ruleinclude)。
756+
配置额外**需要经过 Taro 编译的文件**,使用方式与 [mini.compile.exclude](./config-detail#minicompileexclude) 一致,同 [Rule.include](https://webpack.js.org/configuration/module/#ruleinclude)。例如 Taro 默认不编译 `node_modules` 中的文件,可以通过这个配置让 Taro 编译 `node_modules` 中的文件。
757+
758+
默认值包括 Taro 项目源码目录 src 以及 Taro 相关的 node_modules。如需将 Taro 项目作为 monorepo 项目的子包,则要自行配置 include 以编译其他子包的文件,示例:
758759
759-
例如 Taro 默认不编译 `node_modules` 中的文件,可以通过这个配置让 Taro 编译 `node_modules` 中的文件。
760+
```js title='config/index.js'
761+
export default {
762+
// ...
763+
mini: {
764+
// ...
765+
compile: {
766+
include: [path.resolve(__dirname, '../../package')],
767+
},
768+
},
769+
h5: {
770+
// ...
771+
compile: {
772+
include: [path.resolve(__dirname, '../../package')],
773+
},
774+
},
775+
}
776+
```
760777
761778
### mini.webpackChain
762779
@@ -1279,11 +1296,10 @@ module.exports = {
12791296

12801297
`object`
12811298

1282-
可用于修改、拓展 Webpack 的 **output** 选项,配置项参考[webpack官方文档](https://webpack.js.org/configuration/output/)。
1299+
可用于修改、拓展 Webpack 的 **output** 选项,配置项参考[webpack 官方文档](https://webpack.js.org/configuration/output/)。
12831300

12841301
vite 编译环境下用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
12851302

1286-
12871303
```js
12881304
module.exports = {
12891305
// ...
@@ -1743,9 +1759,27 @@ Web 编译过程的相关配置。
17431759

17441760
`array`
17451761

1746-
配置额外**需要经过 Taro 编译的文件**,使用方式与 [mini.compile.exclude](./config-detail#minicompileexclude) 一致,同 [Rule.include](https://webpack.js.org/configuration/module/#ruleinclude)。
1762+
配置额外**需要经过 Taro 编译的文件**,使用方式与 [mini.compile.exclude](./config-detail#minicompileexclude) 一致,同 [Rule.include](https://webpack.js.org/configuration/module/#ruleinclude)。例如 Taro 默认不编译 `node_modules` 中的文件,可以通过这个配置让 Taro 编译 `node_modules` 中的文件。
1763+
1764+
默认值包括 Taro 项目源码目录 src 以及 Taro 相关的 node_modules。如需将 Taro 项目作为 monorepo 项目的子包,则要自行配置 include 以编译其他子包的文件,示例:
17471765

1748-
例如 Taro 默认不编译 `node_modules` 中的文件,可以通过这个配置让 Taro 编译 `node_modules` 中的文件。
1766+
```js title='config/index.js'
1767+
export default {
1768+
// ...
1769+
mini: {
1770+
// ...
1771+
compile: {
1772+
include: [path.resolve(__dirname, '../../package')],
1773+
},
1774+
},
1775+
h5: {
1776+
// ...
1777+
compile: {
1778+
include: [path.resolve(__dirname, '../../package')],
1779+
},
1780+
},
1781+
}
1782+
```
17491783

17501784
### h5.htmlPluginOption
17511785

0 commit comments

Comments
 (0)