Describe the problem
I have been trying to expose DEBUG flag to debug server side endpoints and hooks through .env using dotenv package but I couldn't succeed.
Describe the proposed solution
It seems vite has some configuration options that can be used, but I'm not sure how to place this to svelte.config.js
vitejs/vite#2676
import { defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
Object.assign(process.env, loadEnv(mode, process.cwd()));
return {
// ...
base: process.env.VITE_ASSET_URL
}
});
Alternatives considered
I was able to workaround this by using dotenv-cli and package.json
"scripts": {
"dev": "dotenv -e .env -- svelte-kit dev --port 4000 --host 0.0.0.0",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"carbon": "gulp -f gulpfile.cjs"
},
Importance
nice to have
Additional Information
If there is an official way, it would be nice to have this in the docs.
Describe the problem
I have been trying to expose DEBUG flag to
debugserver side endpoints and hooks through.envusingdotenvpackage but I couldn't succeed.Describe the proposed solution
It seems vite has some configuration options that can be used, but I'm not sure how to place this to svelte.config.js
vitejs/vite#2676
Alternatives considered
I was able to workaround this by using
dotenv-cliand package.jsonImportance
nice to have
Additional Information
If there is an official way, it would be nice to have this in the docs.