From cbe2fe06572b686f4191bcb3aaf6cbefc461cf12 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sat, 23 Sep 2017 19:11:01 +0100 Subject: [PATCH] Add a task for fast builds with `purs ide` & webpack --- README.md | 22 +++++++++++++++++++--- entry.js | 1 + package.json | 10 ++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 entry.js diff --git a/README.md b/README.md index bbeec65..90daf6f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/entry.js b/entry.js new file mode 100644 index 0000000..4ceadbd --- /dev/null +++ b/entry.js @@ -0,0 +1 @@ +require("./output/Main").main(); diff --git a/package.json b/package.json index bcffc25..c97846a 100644 --- a/package.json +++ b/package.json @@ -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" } }