From 40434dc996cf87d0c0cf3e854c10785b01f659de Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Tue, 2 May 2023 11:55:56 +0100 Subject: [PATCH 1/2] any non-component can be an asset so allow them to be anywhere, not just in `/assets` --- deno.lock | 10 ++++++++++ src/_site/{assets => }/favicon.ico | Bin src/_site/{assets => }/favicon.svg | 0 src/build.ts | 20 ++++++++++++++++---- 4 files changed, 26 insertions(+), 4 deletions(-) rename src/_site/{assets => }/favicon.ico (100%) rename src/_site/{assets => }/favicon.svg (100%) diff --git a/deno.lock b/deno.lock index 8f522ab..0e57df4 100644 --- a/deno.lock +++ b/deno.lock @@ -232,7 +232,17 @@ "https://deno.land/std@0.179.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", "https://deno.land/std@0.179.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32", "https://deno.land/std@0.179.0/fs/copy.ts": "14214efd94fc3aa6db1e4af2b4b9578e50f7362b7f3725d5a14ad259a5df26c8", + "https://deno.land/std@0.179.0/fs/empty_dir.ts": "c3d2da4c7352fab1cf144a1ecfef58090769e8af633678e0f3fabaef98594688", "https://deno.land/std@0.179.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", + "https://deno.land/std@0.179.0/fs/ensure_file.ts": "c38602670bfaf259d86ca824a94e6cb9e5eb73757fefa4ebf43a90dd017d53d9", + "https://deno.land/std@0.179.0/fs/ensure_link.ts": "c0f5b2f0ec094ed52b9128eccb1ee23362a617457aa0f699b145d4883f5b2fb4", + "https://deno.land/std@0.179.0/fs/ensure_symlink.ts": "5006ab2f458159c56d689b53b1e48d57e05eeb1eaf64e677f7f76a30bc4fdba1", + "https://deno.land/std@0.179.0/fs/eol.ts": "f1f2eb348a750c34500741987b21d65607f352cf7205f48f4319d417fff42842", + "https://deno.land/std@0.179.0/fs/exists.ts": "b8c8a457b71e9d7f29b9d2f87aad8dba2739cbe637e8926d6ba6e92567875f8e", + "https://deno.land/std@0.179.0/fs/expand_glob.ts": "e4f56259a0a70fe23f05215b00de3ac5e6ba46646ab2a06ebbe9b010f81c972a", + "https://deno.land/std@0.179.0/fs/mod.ts": "bc3d0acd488cc7b42627044caf47d72019846d459279544e1934418955ba4898", + "https://deno.land/std@0.179.0/fs/move.ts": "4cb47f880e3f0582c55e71c9f8b1e5e8cfaacb5e84f7390781dd563b7298ec19", + "https://deno.land/std@0.179.0/fs/walk.ts": "ea95ffa6500c1eda6b365be488c056edc7c883a1db41ef46ec3bf057b1c0fe32", "https://deno.land/std@0.179.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", "https://deno.land/std@0.179.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", "https://deno.land/std@0.179.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", diff --git a/src/_site/assets/favicon.ico b/src/_site/favicon.ico similarity index 100% rename from src/_site/assets/favicon.ico rename to src/_site/favicon.ico diff --git a/src/_site/assets/favicon.svg b/src/_site/favicon.svg similarity index 100% rename from src/_site/assets/favicon.svg rename to src/_site/favicon.svg diff --git a/src/build.ts b/src/build.ts index 6438de6..805648f 100644 --- a/src/build.ts +++ b/src/build.ts @@ -9,7 +9,8 @@ import { walk } from "https://deno.land/std@0.177.0/fs/walk.ts"; import { create_handler } from "./server.ts"; import { globToRegExp } from "https://deno.land/std@0.182.0/path/glob.ts"; import { copy } from "https://deno.land/std@0.179.0/fs/copy.ts"; -import { normalize } from "https://deno.land/std@0.177.0/path/mod.ts"; +import { expandGlob } from "https://deno.land/std@0.179.0/fs/mod.ts"; +import { dirname, normalize } from "https://deno.land/std@0.177.0/path/mod.ts"; const slashify = (path: string) => normalize(path + "/"); @@ -73,9 +74,20 @@ export const get_svelte_files = async ({ return files; }; -const copy_assets = ( - { site_dir, out_dir }: Partial, -) => copy(site_dir + "assets", out_dir + "assets", { overwrite: true }); +const copy_assets = async ( + { site_dir, out_dir }: Pick, +) => { + for await ( + const file of expandGlob("**/*.!(svelte)", { root: site_dir }) + ) { + const out_file = file.path.replace(site_dir, out_dir); + + await ensureDir(dirname(out_file)); + await copy(file.path, out_file, { + overwrite: true, + }); + } +}; const rebuild = async ({ base, From 45ee5586ed4dccd09c971c26a4ff67a43e12a01e Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Wed, 3 May 2023 10:17:18 +0100 Subject: [PATCH 2/2] Update src/build.ts Co-authored-by: Max Duval --- src/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.ts b/src/build.ts index 123c686..5162da1 100644 --- a/src/build.ts +++ b/src/build.ts @@ -9,7 +9,7 @@ import { walk } from "https://deno.land/std@0.177.0/fs/walk.ts"; import { create_handler } from "./server.ts"; import { globToRegExp } from "https://deno.land/std@0.182.0/path/glob.ts"; import { copy } from "https://deno.land/std@0.179.0/fs/copy.ts"; -import { expandGlob } from "https://deno.land/std@0.179.0/fs/mod.ts"; +import { expandGlob } from "https://deno.land/std@0.177.0/fs/mod.ts"; import { dirname, normalize } from "https://deno.land/std@0.177.0/path/mod.ts"; const slashify = (path: string) => normalize(path + "/");