-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
The documentation for paths.assets says it requires and "absolute path", but any value not specifying a scheme (e.g. https://, http://) will be rejected with the following error:
config.kit.paths.assets option must be an absolute path, if specified. See https://kit.svelte.dev/docs/configuration#paths
Any path starting with a / is a valid absolute path, so either the documentation needs updating or the validation check needs to be reworked, here:
kit/packages/kit/src/core/config/options.js
Line 169 in f766a54
| if (!/^[a-z]+:\/\//.test(input)) { |
My guess is the reason for implementing this feature was to host assets from a CDN which lead to the current validation. However, there are equally valid uses for this setting that would benefit from not having to specify the domain.
In my case, I'm using the static adapter (SPA) with the pages and assets settings defined. I want to serve all static assets from /static/* but the only way to get this to work with the %svelte.assets% variable is to hard code the domain. To avoid this I at least need to hard code the /static value for any of my own static content referenced in app.html. I haven't confirmed this, but I suppose this hard coding approach would not even work with with the built js files which also need access to the assets prefix.
Reproduction
Logs
❯ npm run build
$ svelte-kit build
> config.kit.paths.assets option must be an absolute path, if specified. See https://kit.svelte.dev/docs/configuration#paths
at eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:632:14)
at eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:798:43)
at eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:784:18)
at eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:784:18)
at eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:784:18)
at validate_config (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:968:9)
at load_config (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:945:20)
at async eval (file:///home/projects/sveltejs-kit-template-default-7pbyt8/node_modules/@sveltejs/kit/dist/cli.js:1080:19)System Info
System:
OS: Linux 5.16 Arch Linux
CPU: (24) x64 AMD Ryzen Threadripper 1920X 12-Core Processor
Memory: 43.97 GB / 62.71 GB
Container: Yes
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 17.4.0 - /usr/bin/node
npm: 8.5.0 - /usr/bin/npm
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.17
@sveltejs/adapter-static: ^1.0.0-next.28 => 1.0.0-next.28
@sveltejs/kit: next => 1.0.0-next.278
svelte: ^3.44.0 => 3.46.4Severity
annoyance
Additional Information
No response