File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
packages/solutions/app-tools/src/builder Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @modern-js/app-tools ' : patch
3
+ ---
4
+
5
+ feat: support rsbuild modify config hook
6
+
7
+ feat: 支持 rsbuild 修改配置的 Hook 函数
Original file line number Diff line number Diff line change @@ -59,12 +59,14 @@ async function applyBuilderPlugins<B extends Bundler>(
59
59
builderPluginAdapterBasic,
60
60
builderPluginAdapterHtml,
61
61
builderPluginAdapterSSR,
62
+ builderPluginAdapterHooks,
62
63
} = await import ( '../shared/builderPlugins/index.js' ) ;
63
64
64
65
builder . addPlugins ( [
65
66
builderPluginAdapterBasic ( ) ,
66
67
builderPluginAdapterSSR ( options ) ,
67
68
builderPluginAdapterHtml ( options ) ,
69
+ builderPluginAdapterHooks ( options ) ,
68
70
] ) ;
69
71
70
72
builder . addPlugins ( [ builderPluginAdapterCopy ( options ) ] , {
Original file line number Diff line number Diff line change
1
+ import type { RsbuildPlugin } from '@rsbuild/core' ;
2
+ import type { Bundler } from '../../../types' ;
3
+ import type { BuilderOptions } from '../types' ;
4
+
5
+ export const builderPluginAdapterHooks = < B extends Bundler > (
6
+ options : BuilderOptions < B > ,
7
+ ) : RsbuildPlugin => ( {
8
+ name : 'builder-plugin-support-modern-hooks' ,
9
+ setup ( api ) {
10
+ const _internalContext = options . appContext . _internalContext ;
11
+ const hooks = _internalContext . pluginAPI ?. getHooks ( ) ;
12
+ api . modifyBundlerChain ( async ( chain , utils ) => {
13
+ await hooks ?. modifyBundlerChain . call ( chain , utils ) ;
14
+ } ) ;
15
+ api . modifyRsbuildConfig ( async ( config , utils ) => {
16
+ await hooks ?. modifyRsbuildConfig . call ( config , utils ) ;
17
+ } ) ;
18
+ api . modifyRspackConfig ( async ( config , utils ) => {
19
+ await hooks ?. modifyRspackConfig . call ( config , utils ) ;
20
+ } ) ;
21
+ api . modifyWebpackChain ( async ( chain , utils ) => {
22
+ await hooks ?. modifyWebpackChain . call ( chain , utils ) ;
23
+ } ) ;
24
+ api . modifyWebpackConfig ( async ( config , utils ) => {
25
+ await hooks ?. modifyWebpackConfig . call ( config , utils ) ;
26
+ } ) ;
27
+ } ,
28
+ } ) ;
Original file line number Diff line number Diff line change 1
1
export * from './adapterBasic' ;
2
2
export * from './adapterHtml' ;
3
3
export * from './adapterSSR' ;
4
+ export * from './builderHooks' ;
You can’t perform that action at this time.
0 commit comments