Skip to content

Commit b1cffee

Browse files
authored
docs: add how to skip the preprocessing of less/scss files (#623)
1 parent cc02815 commit b1cffee

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

website/docs/en/guide/faq/features.mdx

+33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Features FAQ
22

3+
## Style Processing
4+
5+
### How to skip the preprocessing of Less / Sass files in bundleless mode?
6+
7+
Bundleless means that each source file is compiled and built separately, which can be understood as the process of code conversion of source files only. To skip the preprocessing of `.less/.scss` files, you need to:
8+
9+
1. Set `source.entry` to remove `.less/.scss` files from the entry.
10+
2. Set `output.copy` to copy `.less/.scss` files to the output directory.
11+
3. Set `redirect.style` to `false` to disable the redirect behavior for the import path of `.less/.scss` files.
12+
13+
Below is an example of skipping the `.scss` file processing. All `.scss` files in `src` will be copied to the output directory and retained with consistent relative paths.
14+
15+
```ts title="rslib.config.ts"
16+
export default defineConfig({
17+
lib: [
18+
{
19+
// ...
20+
source: {
21+
entry: {
22+
index: ['./src/**', '!src/**/*.scss'],
23+
},
24+
},
25+
output: {
26+
copy: [{ from: '**/*.scss', context: path.join(__dirname, 'src') }],
27+
},
28+
redirect: {
29+
style: false,
30+
},
31+
},
32+
],
33+
});
34+
```
35+
336
## Code Minification
437

538
### How to preserve all comments in the output files?

website/docs/zh/guide/faq/features.mdx

+33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# 功能类问题
22

3+
## 样式处理
4+
5+
### bundleless 模式如何跳过对 Less / Sass 等文件的预处理?
6+
7+
bundleless 是指对每个源文件单独进行编译构建,可以理解为仅对源文件进行代码转换的过程。跳过对 `.less/.scss` 文件的预处理需要:
8+
9+
1. 设置 `source.entry``.less/.scss` 文件从入口里移除。
10+
2. 设置 `output.copy``.less/.scss` 文件拷贝到产物目录。
11+
3. 设置 `redirect.style``false` 禁用对 `.less/.scss` 文件导入路径的重定向行为。
12+
13+
下面是一个跳过 `.scss` 文件处理的例子,`src` 里面所有的 `.scss` 文件都会被拷贝到产物目录下并且保留一致的相对路径。
14+
15+
```ts title="rslib.config.ts"
16+
export default defineConfig({
17+
lib: [
18+
{
19+
// ...
20+
source: {
21+
entry: {
22+
index: ['./src/**', '!src/**/*.scss'],
23+
},
24+
},
25+
output: {
26+
copy: [{ from: '**/*.scss', context: path.join(__dirname, 'src') }],
27+
},
28+
redirect: {
29+
style: false,
30+
},
31+
},
32+
],
33+
});
34+
```
35+
336
## 代码压缩
437

538
### 如何保留产物文件代码中的注释?

0 commit comments

Comments
 (0)