diff --git a/jscomp/bsb/templates/react/README.md b/jscomp/bsb/templates/react/README.md index 1d39274cc8..1cbd4956c0 100644 --- a/jscomp/bsb/templates/react/README.md +++ b/jscomp/bsb/templates/react/README.md @@ -1,6 +1,6 @@ # ${bsb:name} -Run this project: +## Run this project: ``` npm install @@ -8,7 +8,14 @@ npm start # in another tab npm run webpack ``` - After you see the webpack compilation succeed (the `npm run webpack` step), open up the nested html files in `src/*` (**no server needed!**). Then modify whichever file in `src` and refresh the page to see the changes. **For more elaborate ReasonReact examples**, please see https://github.com/reasonml-community/reason-react-example + +## Build this project + +``` +npm run build +npm run webpack:build +``` + diff --git a/jscomp/bsb/templates/react/bsconfig.json b/jscomp/bsb/templates/react/bsconfig.json index 39a561f701..82fbae78ee 100644 --- a/jscomp/bsb/templates/react/bsconfig.json +++ b/jscomp/bsb/templates/react/bsconfig.json @@ -12,7 +12,7 @@ "subdirs" : true }, "package-specs": [{ - "module": "commonjs", + "module": "es6", "in-source": true }], "suffix": ".bs.js", diff --git a/jscomp/bsb/templates/react/package.json b/jscomp/bsb/templates/react/package.json index 5da7e9fa6d..75cbbfa7d4 100644 --- a/jscomp/bsb/templates/react/package.json +++ b/jscomp/bsb/templates/react/package.json @@ -6,7 +6,8 @@ "start": "bsb -make-world -w", "clean": "bsb -clean-world", "test": "echo \"Error: no test specified\" && exit 1", - "webpack": "webpack -w" + "webpack": "webpack -w", + "webpack:build": "NODE_ENV=production webpack" }, "keywords": [ "BuckleScript" @@ -14,12 +15,13 @@ "author": "", "license": "MIT", "dependencies": { - "react": "^15.4.2", - "react-dom": "^15.4.2", - "reason-react": ">=0.3.0" + "react": "^16.2.0", + "react-dom": "^16.2.0", + "reason-react": ">=0.3.4" }, "devDependencies": { "bs-platform": "^${bsb:bs-version}", - "webpack": "^3.8.1" + "webpack": "^4.0.1", + "webpack-cli": "^2.0.10" } } diff --git a/jscomp/bsb/templates/react/webpack.config.js b/jscomp/bsb/templates/react/webpack.config.js index e7162c0183..45db307fa2 100644 --- a/jscomp/bsb/templates/react/webpack.config.js +++ b/jscomp/bsb/templates/react/webpack.config.js @@ -1,8 +1,11 @@ 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,