-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support rsbuild modify config hook
- Loading branch information
Showing
4 changed files
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@modern-js/app-tools': minor | ||
--- | ||
|
||
feat: support rsbuild modify config hook | ||
|
||
feat: 支持 rsbuild 修改配置的 Hook 函数 |
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
28 changes: 28 additions & 0 deletions
28
packages/solutions/app-tools/src/builder/shared/builderPlugins/builderHooks.ts
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,28 @@ | ||
import type { RsbuildPlugin } from '@rsbuild/core'; | ||
import type { Bundler } from '../../../types'; | ||
import type { BuilderOptions } from '../types'; | ||
|
||
export const builderPluginAdapterHooks = <B extends Bundler>( | ||
options: BuilderOptions<B>, | ||
): RsbuildPlugin => ({ | ||
name: 'builder-plugin-support-modern-hooks', | ||
setup(api) { | ||
const _internalContext = options.appContext._internalContext; | ||
const hooks = _internalContext.pluginAPI?.getHooks(); | ||
api.modifyBundlerChain(async (chain, utils) => { | ||
await hooks?.modifyBundlerChain.call(chain, utils); | ||
}); | ||
api.modifyRsbuildConfig(async (config, utils) => { | ||
await hooks?.modifyRsbuildConfig.call(config, utils); | ||
}); | ||
api.modifyRspackConfig(async (config, utils) => { | ||
await hooks?.modifyRspackConfig.call(config, utils); | ||
}); | ||
api.modifyWebpackChain(async (chain, utils) => { | ||
await hooks?.modifyWebpackChain.call(chain, utils); | ||
}); | ||
api.modifyWebpackConfig(async (config, utils) => { | ||
await hooks?.modifyWebpackConfig.call(config, utils); | ||
}); | ||
}, | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/solutions/app-tools/src/builder/shared/builderPlugins/index.ts
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,3 +1,4 @@ | ||
export * from './adapterBasic'; | ||
export * from './adapterHtml'; | ||
export * from './adapterSSR'; | ||
export * from './builderHooks'; |