Open KamranKhan-Dev opened 4 years ago
To make it work server side, do this:
server: {
input: config.server.input(),
output: config.server.output(),
plugins: [
replace({
...sapperEnv(),
'process.browser': false,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
Make sure that your env keys starts with SAPPER_APP
like this SAPPER_APP_DB_HOST=localhost
@topazrn it doesn't seem to be working. An env variable, which does work in the client, stays undefined
on the server.
Hmm, weird. It works for me though. In multiple projects. Here's my rollup.config.js file in case you missed something. rollup.config.js.txt
@topazrn it sadly doesn't work for me. My rollup.config.js
looks similar and the sapper-environment
is installed as dependency.
@topazrn should it also work for node scripts, which can run separately?
I think it's worth pointing out in the documentation that this package doesn't work on the server side. It does work when you're running
sapper dev
, but not when you're running theExpress
orPolka
servers throughnode __sapper__/build
.