-
Notifications
You must be signed in to change notification settings - Fork 131
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
1280610
commit 8dfacb9
Showing
3 changed files
with
72 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,46 @@ | ||
import { build } from '@e2e/helper'; | ||
import { expect, test } from '@playwright/test'; | ||
|
||
function isIncludeFile(filenames: string[], includeFilename: string) { | ||
return filenames.some((filename) => filename.includes(includeFilename)); | ||
} | ||
|
||
test('should allow to configure additional assets', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
}); | ||
|
||
const files = await rsbuild.unwrapOutputJSON(); | ||
const filenames = Object.keys(files); | ||
|
||
const indexJs = await rsbuild.getIndexFile(); | ||
expect(indexJs.content).toContain('data:application/json5;base64,'); | ||
|
||
expect( | ||
isIncludeFile(filenames, 'dist/static/assets/test-temp-large.json5'), | ||
).toBeTruthy(); | ||
expect( | ||
isIncludeFile(filenames, 'dist/static/assets/test-temp-small.json5'), | ||
).toBeFalsy(); | ||
}); | ||
|
||
test('should allow to disable emit for additional assets', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
output: { | ||
emitAssets: false, | ||
}, | ||
}, | ||
}); | ||
|
||
const files = await rsbuild.unwrapOutputJSON(); | ||
const filenames = Object.keys(files); | ||
|
||
expect( | ||
isIncludeFile(filenames, 'dist/static/assets/test-temp-large.json5'), | ||
).toBeFalsy(); | ||
expect( | ||
isIncludeFile(filenames, 'dist/static/assets/test-temp-small.json5'), | ||
).toBeFalsy(); | ||
}); |
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,21 @@ | ||
import { writeFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
writeFileSync( | ||
join(__dirname, 'src/test-temp-small.json5'), | ||
JSON.stringify({ a: 1 }), | ||
); | ||
writeFileSync( | ||
join(__dirname, 'src/test-temp-large.json5'), | ||
JSON.stringify({ a: '1'.repeat(10000) }), | ||
); | ||
|
||
export default defineConfig({ | ||
source: { | ||
assetsInclude: /\.json5$/, | ||
}, | ||
output: { | ||
filenameHash: false, | ||
}, | ||
}); |
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,5 @@ | ||
import large from './test-temp-large.json5'; | ||
import small from './test-temp-small.json5'; | ||
|
||
console.log(large); | ||
console.log(small); |