mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 10:33:43 +08:00
fix(@angular-devkit/build-angular): correctly handle scripts when using subresource-integrity option
Fixes #19829
This commit is contained in:
parent
3db8c6e464
commit
d0cc0cbda3
@ -20,7 +20,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
|
||||
const { result } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
harness.expectFile('dist/index.html').content.toContain('integrity=');
|
||||
harness.expectFile('dist/index.html').content.not.toContain('integrity=');
|
||||
});
|
||||
|
||||
it(`does not add integrity attribute when 'false'`, async () => {
|
||||
@ -32,7 +32,7 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
|
||||
const { result } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
harness.expectFile('dist/index.html').content.toContain('integrity=');
|
||||
harness.expectFile('dist/index.html').content.not.toContain('integrity=');
|
||||
});
|
||||
|
||||
it(`does add integrity attribute when 'true'`, async () => {
|
||||
@ -46,5 +46,25 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
|
||||
expect(result?.success).toBe(true);
|
||||
harness.expectFile('dist/index.html').content.toMatch(/integrity="\w+-[A-Za-z0-9\/\+=]+"/);
|
||||
});
|
||||
|
||||
it(`does not issue a warning when 'true' and 'scripts' is set.`, async () => {
|
||||
await harness.writeFile('src/script.js', '');
|
||||
|
||||
harness.useTarget('build', {
|
||||
...BASE_OPTIONS,
|
||||
subresourceIntegrity: true,
|
||||
scripts: ['src/script.js'],
|
||||
});
|
||||
|
||||
const { result, logs } = await harness.executeOnce();
|
||||
|
||||
expect(result?.success).toBe(true);
|
||||
harness.expectFile('dist/index.html').content.toMatch(/integrity="\w+-[A-Za-z0-9\/\+=]+"/);
|
||||
expect(logs).not.toContain(
|
||||
jasmine.objectContaining<logging.LogEntry>({
|
||||
message: jasmine.stringMatching(/subresource-integrity/),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -93,6 +93,7 @@ export class ScriptsWebpackPlugin {
|
||||
}
|
||||
|
||||
compilation.assets[filename] = source;
|
||||
compilation.hooks.chunkAsset.call(chunk, filename);
|
||||
}
|
||||
|
||||
apply(compiler: Compiler): void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user