diff --git a/src/plugin/script.ts b/src/plugin/script.ts index 779fbc4..a054b6e 100644 --- a/src/plugin/script.ts +++ b/src/plugin/script.ts @@ -122,6 +122,9 @@ export function script( ...config.esbuildOptions?.define, "import.meta.environment": "'client'", }, + entryNames: "[dir]/[name]-[hash]", + chunkNames: "[dir]/[name]-[hash]", + assetNames: "[dir]/[name]-[hash]", outdir: path.fromFileUrl(outdirURL), plugins: [ denoResolverPlugin({ diff --git a/src/plugin/svg.ts b/src/plugin/svg.ts index 9a27d84..602b14f 100644 --- a/src/plugin/svg.ts +++ b/src/plugin/svg.ts @@ -58,7 +58,8 @@ export function svg( for (const [name, symbols] of Object.entries(spritesheets)) { const svg = svgBuilder.spritesheet(symbols, frugal.config); - const svgPath = path.join("svg", name); + const hash = (await xxhash.create()).update(svg).digest("hex").toString(); + const svgPath = path.join("svg", `${name}-${hash}.svg`); const svgUrl = new URL(svgPath, frugal.config.publicdir); const assetPath = `/${svgPath}`; @@ -122,7 +123,7 @@ class SvgBuilder { const metaSymbol: MetaSymbol = { id, viewBox: viewBox ?? `0 0 ${width} ${height}`, - spritesheet: `${spritesheet}.svg`, + spritesheet, path: svgPath, };