Merge pull request #13 from slamdata/fast-build

Add a task for fast builds with `purs ide` & webpack
This commit is contained in:
Gary Burgess 2017-09-23 20:21:39 +01:00 committed by GitHub
commit b6b6c8d459
3 changed files with 26 additions and 7 deletions

View File

@ -1,7 +1,5 @@
# purescript-halogen-template
[![Dependency status](https://img.shields.io/librariesio/github/slamdata/purescript-halogen-template.svg)](https://libraries.io/github/slamdata/purescript-halogen-template)
This is a template for starting a fresh project using the [purescript-halogen](https://github.com/slamdata/purescript-halogen) library for declarative user interfaces.
## Prerequisites
@ -53,4 +51,22 @@ pulp build --to dist/app.js
If you open `dist/index.html` you should now have a basic working Halogen app.
That's pretty much it. Have fun with Halogen!
You can also use the command:
``` shell
npm run watch
```
To start a process that will watch the source files and trigger a reload whenever they are modified. Alternatively...
## Fast watching with `purs ide`
If you're using an editor that supports `purs ide` or running [`pscid`](https://github.com/kRITZCREEK/pscid) there's an option for getting near-instant builds of the app while you work on it:
``` shell
npm run watch-fast
```
This will start a watch process that uses [Webpack](https://github.com/webpack/webpack) to rebundle the app whenever the _output_ files are changed. Since `purs ide` rebuilds modules on save, this means you can use this much faster bundle-only rebuild script.
:warning: `purs ide` only rebuilds one module at a time, so sometimes the bundle will end up in an inconsistent state, resulting in runtime errors. This occurs when a change is made in one module that breaks other modules that depend on it. The solution is to run a full build when a change like this is made, as the compiler will force you to resolve those errors.

1
entry.js Normal file
View File

@ -0,0 +1 @@
require("./output/Main").main();

View File

@ -2,11 +2,13 @@
"private": true,
"scripts": {
"build": "pulp build --to dist/app.js",
"watch": "pulp -w build --to dist/app.js"
"watch": "pulp -w build --to dist/app.js",
"watch-fast": "webpack --entry ./entry.js --output-filename dist/app.js --progress --watch"
},
"devDependencies": {
"pulp": "^11.0.0",
"purescript": "^0.11.0",
"purescript-psa": "^0.5.0"
"pulp": "^12.0.1",
"purescript": "^0.11.6",
"purescript-psa": "^0.5.1",
"webpack": "^3.6.0"
}
}