halogen-websocket-ipc-playzone/README.md

92 lines
4.1 KiB
Markdown
Raw Permalink Normal View History

# Halogen Template
2016-01-18 22:17:22 +01:00
2020-06-30 03:32:28 +02:00
### Quick Start
```sh
git clone https://github.com/purescript-halogen/purescript-halogen-template.git halogen-project
cd halogen-project
npm install
npm run build
npm run serve
```
### Introduction
This is a template for starting a fresh project with the [Halogen](https://github.com/purescript-halogen/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.
2020-06-30 03:32:28 +02:00
- The [Real World Halogen](https://github.com/thomashoneyman/purescript-halogen-realworld) application and guide. Note that the published article is written for the older halogen v4, but the code and comments cover the current halogen v5.
- 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
2020-06-30 03:32:28 +02:00
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.x
### Initial Setup
2016-01-18 22:17:22 +01:00
**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
```
2020-06-30 03:32:28 +02:00
Then, install the PureScript compiler, the [Spago](https://github.com/purescript/spago) package manager and build tool, and the [Parcel](https://github.com/parcel-bundler/parcel) bundler. You may either install PureScript tooling _globally_, to reduce duplicated `node_modules` across projects, or _locally_, so that each project uses specific versions of the tools.
2016-01-18 22:17:22 +01:00
2020-06-30 03:32:28 +02:00
To install the toolchain globally:
```sh
npm install -g purescript spago parcel
2016-01-18 22:17:22 +01:00
```
2020-06-30 03:32:28 +02:00
To install the toolchain locally (reads `devDependencies` from `package.json`):
```sh
npm install
```
2016-01-18 22:17:22 +01:00
2020-06-30 03:32:28 +02:00
### Building
2016-01-18 22:17:22 +01:00
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
```
2020-06-30 03:32:28 +02:00
### Launching the App
You can launch your app in the browser with:
2016-01-18 22:17:22 +01:00
```sh
2020-06-30 03:32:28 +02:00
# An alias for `parcel dev/index.html --out-dir dev-dist --open`
npm run serve
```
2020-06-30 03:32:28 +02:00
### Development Cycle
If you're using an [editor](https://github.com/purescript/documentation/blob/master/ecosystem/Editor-and-tool-support.md#editors) that supports [`purs ide`](https://github.com/purescript/purescript/tree/master/psc-ide) or are running [`pscid`](https://github.com/kRITZCREEK/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, then you will need to manually re-run `npm run build`. Even with automatic recompilation, a manual rebuild is occasionally required, such as when you add, remove, or modify module names, or notice any other unexpected behavior.
### Production
When you are ready to create a minified bundle for deployment, run the following command:
```sh
npm run build-prod
```
2020-06-30 03:32:28 +02:00
Parcel output appears in the `./dist/` directory.
2020-06-30 03:32:28 +02:00
You can test the production output locally with a tool like [`http-server`](https://github.com/http-party/http-server#installation). It seems that `parcel` should also be able to accomplish this, but it unfortunately will only serve development builds locally.
```sh
2020-06-30 03:32:28 +02:00
npm install -g http-server
http-server dist -o
```
2020-06-30 03:32:28 +02:00
If everything looks good, you can then upload the contents of `dist` to your preferred static hosting service.