Closed hybridherbst closed 4 months ago
I'd recommend using symlinks in that case. For example, linking someDirectoryOnDisk
to someDevDirectory/src/albums
will let you use import.meta.glob
.
I see. So I would
import.meta.glob
(with eager
and ?url
?) from +page.server.ts
or +layout.server.ts
and return the data there+page.svelte
Does that sound right?
I guess that would work.
I'll close this for now as I don't know how to clarify it.
The readme currently notes:
However, I keep coming back to this plugin because of the glob and dynamic import limitations in vite, so I thought I'd ask here if that is actually an expected usecase, and potentially some notes on that can go into the readme.
Consider an example structure for a photo albums project, and some photos have a story markdown file.
The photo album is on a specific location on disk, unrelated to the vite project (using sveltekit here, but shouldn't matter for the question). There are some topics and subtopics where photos are categorized in.
It is not viable nor desired to just copy the entire set of photo albums into the
public
directory.Somewhere else on disk, we have a svelte project:
Would you say that is a typical usecase for vite-plugin-static-copy?
The flow would be:
vite.config.ts
and usevite-plugin-static-copy
to ensure the files end up in the build+page.server.ts
to pass all the relative paths to+page.svelte
It feels "glued together" compared to letting vite handle all imports and file copying, but I can't figure out if/how that would work given the limitations of
import.meta.glob
and dynamicimport
with a single variable. Letting vite handle it would also allow using image optimizations etc., that seem harder to add this way.