halogen-websocket-ipc-playzone/README.md

58 lines
2.6 KiB
Markdown
Raw Normal View History

# Halogen Template
2016-01-18 22:17:22 +01:00
This is a template for starting a fresh project with the [Halogen](https://github.com/slamdata/purescript-halogen) library for writing declarative, type-safe user interfaces.
2016-01-18 22:17:22 +01:00
You can learn more about Halogen with these resources:
2016-01-18 22:17:22 +01:00
- The [Halogen documentation](https://github.com/purescript-halogen/purescript-halogen/tree/master/docs), which includes a quick start guide and a concepts reference.
- The [Learn Halogen](https://github.com/jordanmartinez/learn-halogen) learning repository.
- The [Real World Halogen](https://github.com/thomashoneyman/purescript-halogen-realworld) application and guide.
- The [API documentation](https://pursuit.purescript.org/packages/purescript-halogen) on Pursuit
2016-01-18 22:17:22 +01:00
You can chat with other Halogen users on the [PureScript Discourse](https://discourse.purescript.org), or join the [Functional Programming Slack](https://functionalprogramming.slack.com) ([invite link](https://fpchat-invite.herokuapp.com/)) in the `#purescript` and `#purescript-beginners` channels.
2016-01-18 22:17:22 +01:00
## Getting started
**Prerequisites:** This template assumes you already have Git and Node.js installed with `npm` somewhere on your path.
First, clone the repository and step into it:
2016-01-18 22:17:22 +01:00
```sh
git clone https://github.com/purescript-halogen/purescript-halogen-template.git halogen-project
cd halogen-project
2016-01-18 22:17:22 +01:00
```
Then, install the PureScript compiler, the [Spago](https://github.com/purescript/spago) package manager and build tool, and [Webpack](https://github.com/webpack/webpack) bundler locally:
2016-01-18 22:17:22 +01:00
```shell
2017-02-28 01:31:13 +01:00
npm install
2016-01-18 22:17:22 +01:00
```
This will automatically trigger Spago to install the PureScript library dependencies for this project.
2016-01-18 22:17:22 +01:00
## Building
You can now build the PureScript source code with:
2016-01-18 22:17:22 +01:00
```sh
# An alias for `spago build`
2016-01-18 22:17:22 +01:00
npm run build
```
You can produce a bundled JS file you can run in the browser with:
2016-01-18 22:17:22 +01:00
```sh
# An alias for `spago bundle-app --to dist/app.js`
npm run bundle
```
This deposits a bundled JS file named `app.js` in the `dist` directory. You can view your running Halogen app by opening the `dist/index.html` file.
Alternatively, if you use an editor that supports `purs ide` or if you are running [`pscid`](https://github.com/kRITZCREEK/pscid), then you can get near-instant builds of the app while you work:
```sh
npm run bundle:watch
```
: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.