Skip to content

Commit

Permalink
Merge pull request #61 from PaulBlanche/fix/asset-hash
Browse files Browse the repository at this point in the history
script and svg with hash in name
  • Loading branch information
PaulBlanche authored Aug 20, 2023
2 parents d3be6c2 + 570798d commit fa80947
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/plugin/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions src/plugin/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down Expand Up @@ -122,7 +123,7 @@ class SvgBuilder {
const metaSymbol: MetaSymbol = {
id,
viewBox: viewBox ?? `0 0 ${width} ${height}`,
spritesheet: `${spritesheet}.svg`,
spritesheet,
path: svgPath,
};

Expand Down

0 comments on commit fa80947

Please sign in to comment.