- ReasonML Quick Start Guide
- Raphael Rafatpanah Bruno Joseph D'mello
- 204字
- 2021-07-02 12:34:17
Setting up a ReasonReact project
To create a new ReasonReact project, run the following command:
bsb -init my-reason-react-app -theme react
cd my-reason-react-app
After opening our text editor, we see that a couple of things have changed. The package.json file lists the relevant React and webpack dependencies. Let's install them:
npm install
We also have the following webpack-related npm scripts:
"webpack": "webpack -w",
"webpack:production": "NODE_ENV=production webpack"
In bsconfig.json, we have a new field that turns on JSX for ReasonReact:
"reason": {
"react-jsx": 2
},
We have a simple webpack.config.js file:
const path = require("path");
const outputDir = path.join(__dirname, "build/");
const isProd = process.env.NODE_ENV === "production";
module.exports = {
entry: "./src/Index.bs.js",
mode: isProd ? "production" : "development",
output: {
path: outputDir,
publicPath: outputDir,
filename: "Index.js"
}
};
Note how the configured entry point is "./src/Index.bs.js", which makes sense since, by default, "in-source" is set to true in bsconfig.json. The rest is just normal webpack stuff.
To run this project, we need to run both bsb and webpack:
npm start
/* in another shell */
npm run webpack
/* in another shell */
php -S localhost:3000
Since the index.html file is located within the src directory, we visit http://localhost:3000/src to see the default application.
- RCNP實(shí)驗指南:構(gòu)建高級的路由互聯(lián)網(wǎng)絡(luò)(BARI)
- 物聯(lián)網(wǎng)檢驗檢測技術(shù)
- Django 2 by Example
- 物聯(lián)網(wǎng)與無線傳感器網(wǎng)絡(luò)
- Mastering JavaFX 10
- 世界互聯(lián)網(wǎng)發(fā)展報告·2019
- 物聯(lián)網(wǎng)通信技術(shù)
- 面向5G-Advanced的關(guān)鍵技術(shù)
- Getting Started with nopCommerce
- Microsoft Power Platform Enterprise Architecture
- 新媒體交互藝術(shù)
- 智能物聯(lián)安防視頻技術(shù)基礎(chǔ)與應(yīng)用
- 網(wǎng)絡(luò)空間作戰(zhàn):機(jī)理與籌劃
- 天下一家:網(wǎng)絡(luò)聯(lián)通世界(科學(xué)新導(dǎo)向叢書)
- 邊緣計算及其資源管理技術(shù)