sveltekit nodejs adapter: Allow passing config.kit.paths.assets dynamically from environment variable
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Hi,
We're building SvelteKit app into a Docker image using SvelteKit Node.js adapter.
We'd like to use a single Docker image in all environments but set a different CDN URL (config.kit.paths.assets) based on where it runs (dev/staging/production; different production AWS regions around the World).
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: preprocess(),
kit: {
paths: {
assets: "\${process.env.CDN_URL}",
},
adapter: node({
out: 'build',
precompress: true,
envPrefix: '',
}),
},
};
When we tried to set config.kit.paths.assets to a dynamic value like this, the build failed on validation
Error: config.kit.paths.assets option must be an absolute path, if specified. See https://kit.svelte.dev/docs/configuration#paths
Describe the proposed solution
We'd like to relax config.kit.paths.assets validation (https://kit.svelte.dev/docs/configuration#paths) to allows dynamic values like "${process.env.CDN_URL}", that can be resolved in the runtime by Node.
We'd like to pass this CDN_URL environment variable to the Docker (Kubernetes) container in the runtime based on where it runs.
Alternatives considered
- A global CDN URL. This is not something our customer allows.
- Run
sedreplacement during the container boot time. This might work but feels too brittle.
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SvelteKit Node.js adapter and the validation for config.kit.paths.assets described in the issue. Trace how the value is handled during the build and at runtime, then verify the built Docker/Kubernetes application can receive CDN_URL at runtime without rejecting the dynamic value during validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, javascript, kubernetes, node.js
- Domain
- backend, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100