b3ng91 / hello-jsoo-esy

A simple js_of_ocaml workflow with Reason and esy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hello-jsoo-esy

A project that includes the minimum configuration for a js_of_ocaml project using Reason and Esy.

It also includes an example showing how to integrate existing js_of_ocaml bindings: jsoo-is-sorted.

Usage

You need Esy, you can install the beta using npm:

npm install -g esy

Install the project dependencies and build the project:

esy # ocaml dependencies
yarn # js dependencies (can use npm too)
esy build:watch
# in another tab
yarn webpack

After you see the webpack compilation succeed (the yarn webpack step), open up build/index.html (no server needed!). Then modify Hello.re file in src and refresh the page to see the changes.

Run Project with Server

To run with the webpack development server run yarn server and view in the browser at http://localhost:8000. Running in this environment provides hot reloading and support for routing; just edit and save the file and the browser will automatically refresh.

To use a port other than 8000 set the PORT environment variable (PORT=8080 yarn server).

Build for Production

yarn clean
esy build:prod # without sourcemaps, minified
yarn webpack:production

This will replace the development artifact build/Index.js for an optimized version as well as copy src/index.html into build/. You can then deploy the contents of the build directory (index.html and Index.js).

About

A simple js_of_ocaml workflow with Reason and esy

License:MIT License


Languages

Language:OCaml 71.0%Language:JavaScript 18.8%Language:HTML 7.5%Language:Shell 2.7%