git clone --depth 1 https://github.com/purescript-templates/react-basic-hooks.git myApp
cd myApp
npm install -g purescript spago parcel
npm run build
npm run serve
This template for purescript-react-basic-hooks is a direct purescript port of the introductory example of the official React Hooks documentation.
More examples are available in the package repository.
If you notice any problems with the below setup instructions, or have suggestions on how to make the new-user experience any smoother, please create an issue or pull-request.
Compatible with PureScript compiler 13.6
Install tools globally:
npm install -g purescript spago parcel
Initial compilation:
npm run build
Launch webapp:
npm run serve
If you're using an editor that supports purs ide or are running pscid, you simply need to keep the previous npm run serve command running in a terminal. Any save to a file will trigger an incremental recompilation, rebundle, and web page refresh, so you can immediately see your changes.
If your workflow does not support automatic recompilation, or if you add, remove, or modify module names, then you will need to manually re-run npm run build.
When you are ready to create a minified bundle for deployment, run the following command:
npm run build-prod
Parcel output appears in the ./dist/ directory.
You can test the production output locally with a tool like http-server. It seems that parcel should also be able to accomplish this, but it unfortunately will only serve development builds locally.
npm install -g http-server
http-server dist -o
If everything looks good, you can then upload the contents of dist to your preferred static hosting service.
If you'd prefer to install tools on a per-project basis (rather than globally) see this guide.