A tiny helper (v1.0.4, no recent updates) for Svelte/Sapper apps that replaces environment variables with a configurable prefix (default SVELTE_APP_) at build time using Rollup's @rollup/plugin-replace or Webpack's DefinePlugin. Unlike Vite's built-in import.meta.env or dotenv, this package is Rollup/Webpack-only and designed specifically for Svelte/Sapper. No TypeScript types are included. Last published in 2020, it is effectively in maintenance mode.
npm install svelte-environment-variablesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures Rollup to replace environment variables prefixed with SVELTE_APP_ at build time.
Ensure all client-side env vars use the prefix (default 'SVELTE_APP_').
Wrap build script with env-cmd: 'env-cmd npm run dev'
Add preventAssignment: true to replace options.
Migrate to SvelteKit's $env module or Vite's import.meta.env for newer projects.
Run 'npm install svelte-environment-variables'
Ensure @rollup/plugin-replace is configured with ...includeEnv() and that the variable has the correct prefix.
Use 'const includeEnv = require('svelte-environment-variables').default' or switch to ES6 import.No dependency data recorded yet.