sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.61k stars 1.92k forks source link

Support multiple static asset dirs by allowing string arrays for `config.kit.files.assets` #5115

Open janosh opened 2 years ago

janosh commented 2 years ago

Describe the problem

I'd like to get static assets from multiple locations. In this example the SvelteKit site is inside the site/ directory as part of a bigger project and I'd like to use static assets from assets/ and site/static/.

.
├── assets
│   ├── ...
└── site
    ├── src
    ├── static
    └── ...

Describe the proposed solution

config.kit.files.assets could support arrays:

// svelte.config.jg

export default {
  kit: {
    adapter: adapter(),

    files: {
      assets:[ `../assets`, `./static` ],
    },
  },
}

This currently raises

config.kit.files.assets should be a string, if specified

Alternatives considered

Create an alias of assets/ in site/static/. It works but feels hacky.

Importance

nice to have

Additional Information

No response

jochemvogel commented 2 years ago

Would love to see this. I'm trying to exclude the static/img folder from the { files } in my service worker, because of the size.

I now do it with a workaround, but feels not very natural. Is there another solution for this problem?

Workaround: const cachedFiles = files.filter(file => !file.startsWith('/img');

alexanderl19 commented 1 year ago

Would also love to see this. It looks like vite only supports one public folder, so this might be a vite limitation?