Skip to content

Commit bb89fc5

Browse files
committed
fix(@angular/build): include dataurl option in global stylesheet config hash
The global stylesheet configuration hash did not include the 'dataurl' option from 'BundleStylesheetOptions'. When persistent stylesheet caching is enabled, toggling or changing the 'dataurl' option should invalidate cached stylesheet bundles.
1 parent eb1edeb commit bb89fc5

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-cache-key.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type { BundleStylesheetOptions } from './bundle-options';
2626
* - `publicPath`: Affects relative asset URL rewriting (`url('...')`) inside CSS output.
2727
* - `outputNames`: Affects asset output filename hashing schemes.
2828
* - `inlineFonts`: Controls whether external web font `@import` / `<link>` directives are inlined.
29+
* - `dataurl`: Controls whether referenced assets are inlined as base64 data URIs.
2930
* - `preserveSymlinks`: Controls symlink realpath resolution in monorepos/pnpm workspace packages.
3031
* - `externalDependencies`: Controls which CSS modules/urls are excluded from bundling.
3132
* - `postcssConfig`: Path to custom PostCSS configuration file.
@@ -56,6 +57,7 @@ export function calculateGlobalStylesheetConfigHash(
5657
publicPath: options.publicPath,
5758
outputNames: options.outputNames,
5859
inlineFonts: options.inlineFonts,
60+
dataurl: options.dataurl ?? false,
5961
preserveSymlinks: options.preserveSymlinks,
6062
externalDependencies: options.externalDependencies,
6163
postcssConfig: options.postcssConfiguration?.configPath

packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-cache-key_spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,20 @@ describe('Stylesheet Global Config Hash', () => {
7070
);
7171
expect(hash1).not.toBe(hash2);
7272
});
73+
74+
it('should produce different hashes when dataurl changes', () => {
75+
const hash1 = calculateGlobalStylesheetConfigHash(baseOptions, '1.0.0');
76+
const hash2 = calculateGlobalStylesheetConfigHash({ ...baseOptions, dataurl: true }, '1.0.0');
77+
expect(hash1).not.toBe(hash2);
78+
});
79+
80+
it('should produce the same hash when dataurl is undefined or false', () => {
81+
const hash1 = calculateGlobalStylesheetConfigHash(baseOptions, '1.0.0');
82+
const hash2 = calculateGlobalStylesheetConfigHash(
83+
{ ...baseOptions, dataurl: false },
84+
'1.0.0',
85+
);
86+
expect(hash1).toBe(hash2);
87+
});
7388
});
7489
});

0 commit comments

Comments
 (0)