diff --git a/e2e/cases/html/script-loading/index.test.ts b/e2e/cases/html/script-loading/index.test.ts index 0f1599dc91..02c31d6178 100644 --- a/e2e/cases/html/script-loading/index.test.ts +++ b/e2e/cases/html/script-loading/index.test.ts @@ -37,3 +37,58 @@ test('should allow to set scriptLoading to "module"', async ({ build }) => { expect(html).toContain('', + ); + expect(html).toContain( + '', + ); +}); + +test('should not affect tags generated by `html.tags`', async ({ build }) => { + const rsbuild = await build({ + config: { + output: { + filenameHash: false, + }, + html: { + scriptLoading: 'module', + tags: [ + { + tag: 'script', + attrs: { + src: 'https://example.com/foo.js', + async: true, + }, + }, + ], + }, + }, + }); + + const files = rsbuild.getDistFiles(); + const html = getFileContent(files, 'index.html'); + expect(html).toContain( + '', + ); + expect(html).toContain( + '', + ); +}); diff --git a/e2e/cases/html/script-loading/src/index.html b/e2e/cases/html/script-loading/src/index.html new file mode 100644 index 0000000000..6dbb6b986a --- /dev/null +++ b/e2e/cases/html/script-loading/src/index.html @@ -0,0 +1,7 @@ + + +
+ + + + diff --git a/website/docs/en/config/html/script-loading.mdx b/website/docs/en/config/html/script-loading.mdx index d8d3c64132..869b4334ac 100644 --- a/website/docs/en/config/html/script-loading.mdx +++ b/website/docs/en/config/html/script-loading.mdx @@ -13,6 +13,16 @@ Specifies how `