Allow different scripts for 'build' and 'start'

By default, Glitch will run npm run start whenever project files change. However, Glitch will do exactly the same thing when a project wakes up.

Folks tend to make their build script part of npm run start, but when projects wake up this results in slow startup times due to unnecessary builds.

Possible solution:

Call npm run build only when projects need rebuilding. Projects need rebuilding when watched files have changed, or when the project is freshly remixed.

Called when files change, or project is newly remixed:

  1. npm run build
  2. npm run start

Called when app is re-awoken:

  1. npm run start

FWIW, here’s a hacky script I used to work around it.

HEY. This should be voted.

I happen to be in the same situation. Nowadays, static site generators are pretty used, and it isn’t required to build the whole site when woken up.

For example, I have a Nuxt project that requires to talk with a websocket server. So currently, in “start” command I do,

  • when I’m working on the static site: nuxt generate && node server.js
  • when I’ve already finished working on nuxt: node server.js

So that everytime the site sleeps and wakes up it doesn’t generate the site unnecessarily. Static site lives on dist folder, and is served by express in server.js just because I’m also running a websockets service, but it could be just statically served from dist.

It even would be more lightweight for Glitch servers if that would be possible.