Skip to content

Commit eeafd6c

Browse files
committed
doc
1 parent bca4bb1 commit eeafd6c

File tree

6 files changed

+70
-2
lines changed

6 files changed

+70
-2
lines changed

website/docs/en/guide/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@
2323
"type": "dir",
2424
"name": "migration",
2525
"label": "Migration"
26+
},
27+
{
28+
"type": "dir",
29+
"name": "faq",
30+
"label": "FAQ"
2631
}
2732
]

website/docs/en/guide/faq/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["general", "features", "exceptions"]
1+
["features"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# Features FAQ
2+
3+
## How to preserve all comments in the output files?
4+
5+
By default, Rslib uses SWC to remove comments. The corresponding SWC [jsc.minify.format](https://swc.rs/docs/configuration/minification#jscminifyformat) configuration is
6+
7+
```js
8+
{
9+
comments: 'some', //
10+
preserveAnnotations: true,
11+
}
12+
```
13+
14+
This will only preserve some legal comments and annotations. If you want to preserve all comments, you can refer to the following configuration
15+
16+
```ts title="rslib.config.ts"
17+
export default {
18+
output: {
19+
minify: {
20+
jsOptions: {
21+
minimizerOptions: {
22+
format: {
23+
comments: 'all', // This will preserve all comments
24+
},
25+
},
26+
},
27+
},
28+
},
29+
};
30+
```

website/docs/zh/guide/_meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,10 @@
2323
"type": "dir",
2424
"name": "migration",
2525
"label": "迁移"
26+
},
27+
{
28+
"type": "dir",
29+
"name": "faq",
30+
"label": "常见问题"
2631
}
2732
]

website/docs/zh/guide/faq/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["general", "features", "exceptions"]
1+
["features"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# 功能类问题
2+
3+
## 如何保留产物文件代码中的注释?
4+
5+
默认情况下,Rslib 使用 SWC 清除注释,对应的 SWC 的 [jsc.minify.format](https://swc.rs/docs/configuration/minification#jscminifyformat) 配置为
6+
7+
```js
8+
{
9+
comments: 'some', //
10+
preserveAnnotations: true,
11+
}
12+
```
13+
14+
这将仅保留部分 legal 注释及 annotations。如果你想保留所有注释,可以参考如下配置
15+
16+
```ts title="rslib.config.ts"
17+
export default {
18+
output: {
19+
minify: {
20+
jsOptions: {
21+
minimizerOptions: {
22+
format: {
23+
comments: 'all', // 将保留所有注释
24+
},
25+
},
26+
},
27+
},
28+
},
29+
};
30+
```

0 commit comments

Comments
 (0)