unfortunately, I was not able to find anything in the rollup documentation. I am building a website with Svelte and rollup and need different environment variables for production, testing and development.
This is my scripts section of my package.json:
"scripts": {
"build": "cross-env rollup -c",
"autobuild": "BACKEND_SSL=true SERVER_NAME=some.website.com SERVER_PORT=443 rollup -c -w",
"devbuild": "rollup --environment BACKEND_SSL:false,SERVER_NAME:localhost,SERVER_PORT:4000 -c -w",
"testbuild": "BACKEND_SSL=false SERVER_NAME=localhost SERVER_PORT=4000 rollup -c",
"dev": " run-p start:dev",
"start": "sirv public --single",
"start:dev": "cross-env --max-old-space-size=16000 sirv public --single --dev --cors",
}
I can't figure out how to use the start:dev command with one of the autobuild or testbuild commands. Somehow the environment variables are always the one from the devbuild script, even when I remove all the scripts. Are these variables also specified somewhere else? I tried this:
"start:dev": "cross-env --max-old-space-size=16000 sirv public --single --dev --cors autobuild"
and this:
"start:dev": "cross-env --max-old-space-size=16000 sirv public --single --dev --cors BACKEND_SSL=true SERVER_NAME=api.dev.vipfy.store SERVER_PORT=443 rollup -c -w"
but nothing seems to work. What do I not see here? Is there maybe some actual documentation on sirv? I could only scrape by some information via the -h flag.
Okay, I figured it out. sirv is only a static fileserver, so it has nothing to do with my problem. The solution lies in the run-p command. This is short for npm run all. So I have to do this in my dev script:
"dev": " run-p autobuild start:dev"
So first rollup runs and builds and watches the files and then sirv runs and delievers the compiled files. To be honest, what dumbfounds me most, is that it worked before, where only the start:dev command was executed.