Skip to content

Commit

Permalink
script and svg with hash in name
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBlanche committed Aug 20, 2023
1 parent d3be6c2 commit 570798d
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 570798d

Please sign in to comment.