I have a SvelteKit project and'd like to run some maintenance scripts from the command line. I know how to run scripts with node. The maintenance scripts would refer modules in SvelteKit's $lib
folder which then import other modules and $env
.
How can I run a script in a way that the SvelteKit framework specific functionality imports like $lib and $env are available inside the script code?
E.g.
node src/scripts/myscript.js # How can import $lib here
As kind people in SvelteKit discord pointed out there is vite-node package that does exactly this:
npx vite-node src/scripts/my-sveltekit-script.js
process.env
directly