Skip to content
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

chore: use resolve.alias instead of source.alias #1639

Merged
merged 1 commit into from
Dec 4, 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
12 changes: 9 additions & 3 deletions packages/core/src/node/initRsbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async function createInternalBuildConfig(
root: csrOutDir,
},
},
source: {
resolve: {
alias: {
...detectCustomIconAlias,
'@mdx-js/react': require.resolve('@mdx-js/react'),
Expand All @@ -163,6 +163,8 @@ async function createInternalBuildConfig(
),
'@theme-assets': path.join(DEFAULT_THEME, '../assets'),
},
},
source: {
include: [PACKAGE_ROOT, path.join(cwd, 'node_modules', RSPRESS_TEMP_DIR)],
define: {
'process.env.__IS_REACT_18__': JSON.stringify(reactVersion === 18),
Expand Down Expand Up @@ -245,11 +247,13 @@ async function createInternalBuildConfig(
},
environments: {
web: {
resolve: {
alias: reactCSRAlias,
},
source: {
entry: {
index: CLIENT_ENTRY,
},
alias: reactCSRAlias,
define: {
'process.env.__SSR__': JSON.stringify(false),
},
Expand All @@ -264,11 +268,13 @@ async function createInternalBuildConfig(
...(enableSSG
? {
node: {
resolve: {
alias: reactSSRAlias,
},
source: {
entry: {
index: SSR_ENTRY,
},
alias: reactSSRAlias,
define: {
'process.env.__SSR__': JSON.stringify(true),
},
Expand Down
4 changes: 2 additions & 2 deletions packages/document/docs/en/api/config/config-build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

Used to customize the configurations of Rsbuild. For detailed configurations, please refer to [Rsbuild - Config](https://rsbuild.dev/config/).

- Example: Use [source.alias](https://rsbuild.dev/config/source/alias) to configure path aliases:
- Example: Use [resolve.alias](https://rsbuild.dev/config/resolve/alias) to configure path aliases:

```ts title="rspress.config.ts"
export default defineConfig({
builderConfig: {
source: {
resolve: {
alias: {
'@common': './src/common',
},
Expand Down
6 changes: 3 additions & 3 deletions packages/document/docs/zh/api/config/config-build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

用于自定义 Rsbuild 的配置项,完整配置项请查看 [Rsbuild - 配置](https://rsbuild.dev/zh/config/)。

- 示例:使用 [source.alias](https://rsbuild.dev/config/source/alias) 配置路径别名:
- 示例:使用 [source.alias](https://rsbuild.dev/zh/config/resolve/alias) 配置路径别名:

```ts title="rspress.config.ts"
export default defineConfig({
builderConfig: {
source: {
resolve: {
alias: {
'@common': './src/common',
},
Expand All @@ -20,7 +20,7 @@ export default defineConfig({
});
```

- 示例:使用 [tools.rspack](https://rsbuild.dev/config/tools/rspack) 修改 Rspack 配置,比如注册一个 webpack 或 Rspack 插件。比如:
- 示例:使用 [tools.rspack](https://rsbuild.dev/zh/config/tools/rspack) 修改 Rspack 配置,比如注册一个 webpack 或 Rspack 插件。比如:

```ts title="rspress.config.ts"
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion packages/modern-plugin-rspress/src/lanchDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function launchDoc({
],
},
builderConfig: {
source: {
resolve: {
alias: {
'rspress/runtime': '@rspress/core/runtime',
'rspress/theme': '@rspress/core/theme',
Expand Down
2 changes: 1 addition & 1 deletion packages/theme-default/src/node/source-build-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function SourceBuildPlugin(): RspressPlugin {
return {
name: 'theme-default:source-build',
builderConfig: {
source: {
resolve: {
alias: {
'rspress/theme': path.resolve(ROOT_DIR, './src'),
},
Expand Down
Loading