Skip to content

docs: add how to skip the preprocessing of less/scss files #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions website/docs/en/guide/faq/features.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Features FAQ

## Style Processing

### How to skip the preprocessing of Less / Sass files in bundleless mode?

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:

1. Set `source.entry` to remove `.less/.scss` files from the entry.
2. Set `output.copy` to copy `.less/.scss` files to the output directory.
3. Set `redirect.style` to `false` to disable the redirect behavior for the import path of `.less/.scss` files.

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.

```ts title="rslib.config.ts"
export default defineConfig({
lib: [
{
// ...
source: {
entry: {
index: ['./src/**', '!src/**/*.scss'],
},
},
output: {
copy: [{ from: '**/*.scss', context: path.join(__dirname, 'src') }],
},
redirect: {
style: false,
},
},
],
});
```

## Code Minification

### How to preserve all comments in the output files?
Expand Down
33 changes: 33 additions & 0 deletions website/docs/zh/guide/faq/features.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# 功能类问题

## 样式处理

### bundleless 模式如何跳过对 Less / Sass 等文件的预处理?

bundleless 是指对每个源文件单独进行编译构建,可以理解为仅对源文件进行代码转换的过程。跳过对 `.less/.scss` 文件的预处理需要:

1. 设置 `source.entry` 将 `.less/.scss` 文件从入口里移除。
2. 设置 `output.copy` 将 `.less/.scss` 文件拷贝到产物目录。
3. 设置 `redirect.style` 为 `false` 禁用对 `.less/.scss` 文件导入路径的重定向行为。

下面是一个跳过 `.scss` 文件处理的例子,`src` 里面所有的 `.scss` 文件都会被拷贝到产物目录下并且保留一致的相对路径。

```ts title="rslib.config.ts"
export default defineConfig({
lib: [
{
// ...
source: {
entry: {
index: ['./src/**', '!src/**/*.scss'],
},
},
output: {
copy: [{ from: '**/*.scss', context: path.join(__dirname, 'src') }],
},
redirect: {
style: false,
},
},
],
});
```

## 代码压缩

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