File tree 2 files changed +6
-53
lines changed
e2e/cases/server/public-dir
packages/core/src/plugins
2 files changed +6
-53
lines changed Original file line number Diff line number Diff line change @@ -170,45 +170,6 @@ test('should serve publicDir for preview server correctly', async ({
170
170
await rsbuild . close ( ) ;
171
171
} ) ;
172
172
173
- test ( 'should copy publicDir to the environment distDir when multiple environments' , async ( ) => {
174
- await fse . outputFile ( join ( __dirname , 'public' , 'test-temp-file.txt' ) , 'a' ) ;
175
-
176
- const rsbuild = await build ( {
177
- cwd,
178
- rsbuildConfig : {
179
- environments : {
180
- web1 : {
181
- output : {
182
- distPath : {
183
- root : 'dist-build-web-1' ,
184
- } ,
185
- } ,
186
- } ,
187
- web2 : {
188
- output : {
189
- distPath : {
190
- root : 'dist-build-web-2' ,
191
- } ,
192
- } ,
193
- } ,
194
- } ,
195
- } ,
196
- } ) ;
197
- const files = await rsbuild . unwrapOutputJSON ( ) ;
198
- const filenames = Object . keys ( files ) ;
199
-
200
- expect (
201
- filenames . some ( ( filename ) =>
202
- filename . includes ( 'dist-build-web-1/test-temp-file.txt' ) ,
203
- ) ,
204
- ) . toBeTruthy ( ) ;
205
- expect (
206
- filenames . some ( ( filename ) =>
207
- filename . includes ( 'dist-build-web-2/test-temp-file.txt' ) ,
208
- ) ,
209
- ) . toBeTruthy ( ) ;
210
- } ) ;
211
-
212
173
test ( 'should serve publicDir for preview server with assetPrefix correctly' , async ( {
213
174
page,
214
175
} ) => {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export const pluginServer = (): RsbuildPlugin => ({
23
23
24
24
api . onAfterStartDevServer ( onStartServer ) ;
25
25
api . onAfterStartProdServer ( onStartServer ) ;
26
- api . onBeforeBuild ( async ( { isFirstCompile, environments } ) => {
26
+ api . onBeforeBuild ( async ( { isFirstCompile } ) => {
27
27
if ( ! isFirstCompile ) {
28
28
return ;
29
29
}
@@ -45,22 +45,14 @@ export const pluginServer = (): RsbuildPlugin => ({
45
45
continue ;
46
46
}
47
47
48
- const distPaths = [
49
- ...new Set ( Object . values ( environments ) . map ( ( e ) => e . distPath ) ) ,
50
- ] ;
51
-
52
48
try {
53
49
// async errors will missing error stack on copy, move
54
50
// https://github.com/jprichardson/node-fs-extra/issues/769
55
- await Promise . all (
56
- distPaths . map ( ( distPath ) =>
57
- fs . promises . cp ( normalizedPath , distPath , {
58
- recursive : true ,
59
- // dereference symlinks
60
- dereference : true ,
61
- } ) ,
62
- ) ,
63
- ) ;
51
+ await fs . promises . cp ( normalizedPath , api . context . distPath , {
52
+ recursive : true ,
53
+ // dereference symlinks
54
+ dereference : true ,
55
+ } ) ;
64
56
} catch ( err ) {
65
57
if ( err instanceof Error ) {
66
58
err . message = `Copy public dir (${ normalizedPath } ) to dist failed:\n${ err . message } ` ;
You can’t perform that action at this time.
0 commit comments