-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
597ef40
commit 3dd85dc
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["react", "vue3", "vue2", "svelte", "solid"] | ||
["react", "vue3", "vue2", "preact", "svelte", "solid"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Preact | ||
|
||
In this document, you will learn how to build a Preact application using Rsbuild. | ||
|
||
## Create Preact Project | ||
|
||
You can use `create-rsbuild` to create a project with Rsbuild + Preact. Just execute the following command: | ||
|
||
import { PackageManagerTabs } from '@theme'; | ||
|
||
<PackageManagerTabs | ||
command={{ | ||
npm: 'npm create rsbuild@latest', | ||
yarn: 'yarn create rsbuild', | ||
pnpm: 'pnpm create rsbuild@latest', | ||
bun: 'bun create rsbuild@latest', | ||
}} | ||
/> | ||
|
||
Then select `Preact` when prompted to "Select framework". | ||
|
||
## Use Preact in an existing project | ||
|
||
To compile Preact, you need to register the Rsbuild [Preact Plugin](/plugins/list/plugin-preact). The plugin will automatically add the necessary configuration for Preact builds. | ||
|
||
For example, register in `rsbuild.config.ts`: | ||
|
||
```ts title="rsbuild.config.ts" | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginPreact } from '@rsbuild/plugin-preact'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginPreact()], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["react", "vue3", "vue2", "svelte", "solid"] | ||
["react", "vue3", "vue2", "preact", "svelte", "solid"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Preact | ||
|
||
在这篇文档中,你可以了解到如何基于 Rsbuild 来构建一个 Preact 应用。 | ||
|
||
## 创建 Preact 项目 | ||
|
||
你可以使用 `create-rsbuild` 来创建一个 Rsbuild + Preact 的项目,调用以下命令: | ||
|
||
import { PackageManagerTabs } from '@theme'; | ||
|
||
<PackageManagerTabs | ||
command={{ | ||
npm: 'npm create rsbuild@latest', | ||
yarn: 'yarn create rsbuild', | ||
pnpm: 'pnpm create rsbuild@latest', | ||
bun: 'bun create rsbuild@latest', | ||
}} | ||
/> | ||
|
||
然后在 `Select framework` 时选择 `Preact` 即可。 | ||
|
||
## 在已有项目中使用 Preact | ||
|
||
为了能够编译 Preact,你需要注册 Rsbuild 的 [Preact 插件](/plugins/list/plugin-preact),插件会自动添加 Preact 构建所需的配置。 | ||
|
||
例如,在 `rsbuild.config.ts` 中注册: | ||
|
||
```ts title="rsbuild.config.ts" | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginPreact } from '@rsbuild/plugin-preact'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginPreact()], | ||
}); | ||
``` |