New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to build command to watch for file changes #65
Comments
Personally I use either the normal psc-ide plugins or https://github.com/watchexec/watchexec |
Hi @alex-ketch, and thank you for making the As Justin already noted, if you use psc-ide with some editor you get this rebuilding for free, and if you're not you can use watchexec (e.g. like So in the end it is possible, but not super nice (as you have to install another tool), and I agree that it might be worth to just integrate the file watching into Spago.
|
Here's Stack's implementation of this feature. It's 100 lines, so it should be easy to port here |
Fix up in #126 |
So.. how do you run parcel (or some other custom command) after every time a build is triggered? Something like this would be useful:
|
@dlight I think you need to invert your thinking. Make When you make changes to your source code, spago sees the change and rebundles the app/module, which is seen by parcel and causes parcel to rebuild the page. |
@JordanMartinez if I understand correctly, this require running two long living processes in two terminal tabs, which is what I'm trying to avoid. A workaround is running |
Ah, with that criteria, then yeah, it requires a workaround. |
Just in case it's useful for someone, I ended up writing this script #!/bin/bash
function cleanup {
trap - SIGTERM
kill -- -$$
}
trap cleanup SIGINT SIGTERM EXIT
rm -f dist/*
while [[ ! -f dist/app.js ]]; do sleep 0.01; done && \
parcel serve asset index.html -o dist/index.html > \
>(sed 's/^/(parcel): /') 2>&1 &
spago bundle-app --watch -m App -t dist/app.js #> >(sed 's/^/(spago): /') 2>&1 It runs Spago on the foreground to enable running commands, like The commented out part would prefix Spago's output with I tried working around with |
@dlight just curious about your use-case: why is it a requirement to avoid running two long-lived processes for the watchers? Also you might be interested in #134 which discusses a possible integration with Parcel (so if that would exist you'd only need to run Parcel and it would call the relevant Spago stuff or keep a watcher and run things in order, etc) |
@f-f I just wanted to avoid opening two terminal tabs, that's all And, integration with Parcel sounds awesome! |
Note for new readers, the I'm using a combination of these commands in separate terminals for automatic page reloading upon file changes:
|
I used to use This works for me, thank you.
|
Hi there, and thanks for Spago!
As I was creating a fork of a react-basic-starter to use Spago, I wanted to recommend a way to have the project be auto-built when making changes.
Right now there is in a workaround for people using IDE PureScript, but it would be nice to have an alternative for people who don't use the plugin.
I realize this is a little bit more complicated since Spago uses
purs
under the hood, and unlikepulp
it doesn't support thewatch
flag.As an aside, the project seems to work like a treat combined with Parcel 🎉
The text was updated successfully, but these errors were encountered: