$ npm install -g bs-platform
-
Create directory
$ mkdir reason-parcel && cd reason-parcel
-
Add dependencies
$ yarn add reason-react parcel-bundler
-
Resolve package bs-platform
$ npm link bs-platform
-
Add bsconfig.json
{
"name": "reason-parcel",
"sources": [
"src"
],
"bs-dependencies": [
"reason-react"
],
"reason": {
"react-jsx": 2
},
"bsc-flags": [
"-bs-super-errors"
],
"refmt": 3
}
- Add reason files in
src
directory$mkdir src && touch src/index.re
ReactDOMRe.renderToElementWithId(<div>(ReasonReact.stringToElement("Hello Reason and Parcel"))</div>, "root");
- Add index.html
<!DOCTYPE html>
<html>
<head>
<title>React starter app</title>
</head>
<body>
<div id="root"></div>
<script src="lib/js/src/index.js"></script>
</body>
</html>
- Add scripts in packge.json
"scripts": {
"start": "parcel index.html",
"watch": "bsb -make-world -w"
},
-
Compile Reason files to JavaScript
$ bsb -make-world -w
-
Run Parcel in another terminal.
$ yarn start
-
Create project by bsb -init
$ bsb -init reason-parcel-2 -theme react && cd reason-parcel-2
-
Add parcel
$ yarn add parcel-bundler
-
Change entry point
src="../build/index.js"
->src="index.bs.js"
-
Add script in package.json
"parcel": "parcel src/index.html"
-
Compile Reason files to JavaScript
$ yarn start
-
Run Parcel in another terminal.
$ yarn parcel