A starter project for react-app, if you don't familiar with React with Webpack, the following links is highly recommended.
please use the latest version of following tools:
-
babel-node
is selected in the server-side, which is an executable for running code via Babel that otherwise works like thenode
executable. -
babel-preset-es2015-node5
is selected, so that Babel can transpile ES6. The preset configures Babel so that only ES6 constructs are transpiled that missing from Node.js 5。
Tools:
- webpack as a client-side module build and module loader
- npm as the package manager
- Babel as a transpiler from ES6 to ES5
Dependencies:
babel-loader
enables webpack to transpile JavaScript via Babel.babel-preset-es2015
is a Babel preset for compiling ES6 to plain ES6.webpack-dev-server
adds a hot-reloading development web server to webpack.
npm install
If your app is ready, and you want to check the results, you can execute
npm run build
then the bundle.js
is serving at http://localhost:300/bundle.js
via your koa server,
or you can use hot mode if you want to build
repeatedly to check the code changes:
npm run dev
then the bundle.js
is serving at http://localhost:8080/assets/bundle.js
via webpack-dev-server
remember!!! you should modify the path of file bundle.js
in home.html
manually!
npm start
Open your browser, and visit http://localhost:3000
to check the result