Skip to content

Instantly share code, notes, and snippets.

@antony
Last active September 15, 2019 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antony/255a4a68e7823773d1c2dad5df6fcfea to your computer and use it in GitHub Desktop.
Save antony/255a4a68e7823773d1c2dad5df6fcfea to your computer and use it in GitHub Desktop.
Configuration variables in Svelte / Sapper
import conf from 'config'
const appConfig = Object.keys(conf).reduce((acc, n) => {
acc[`process.env.${n}`] = JSON.stringify(conf[n])
return acc
}, {})
export default {
client: {
...,
plugins: [
...
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode),
...appConfig
}),
...
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment