In Rails 7 with esbuild build, how do I run a script of esbuild fails?

519 Views Asked by At

I have this script that runs when running Rails 7 with esbuild build, this is inside package.json in the scripts attribute, it's ran from the Rails procfile:

esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds

however I often find myself with errors with file configs, however the website I'm working on does not show any errors because the last build was there and working.

I'd like the webpage to bread if there's an esbuild error.

I was wondering how do I run another script that deleted the previous build, I tried this:

esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --onFailure \"rm ./app/assets/builds/application.js && rm ./app/assets/builds/application.js.map\"

However it's saying onFailure is an invalid flag.

Is there a way to make esbuild show the error on the site, or just show any error if the build fails?

0

There are 0 best solutions below