2nd version of my react simple -- Simple React Boilerplate with Webpack and React Router. Fit for every beginners who want to learn react for the first time (like me).
Made it with frustration of ReactJS 😂
must install : npm, node, nodemon.
git clone https://github.com/rizkiandrianto/react-simple-2.git
cd react-simple-2
and thennpm install
npm start
orwebpack-dev-server --hot --progress --colors
npm run build
to build into 1 filebuild.js
andbuild.min.js
.- Uncomment script
build.min.js
and comment thebuild.js
line inindex.html
- If you decide to use Apache or Nginx server, copy
dist
folder only to your server. (If you decide to this node server, you don't need steps 3) - run
nodemon (or node or pm2) server/server.prod.js
How to Reproduce this project, (init based on http://bit.ly/react-es6-webpack-babel)
- Install Webpack Dev Server globaly :
npm install -g webpack-dev-server
- Create New Folder (name it react-simple for example) and enter it
npm init
npm install --save react react-dom
npm install --save-dev babel-loader babel-core babel-preset-es2015 babel-preset-react
npm install --save webpack
and if it's shown webpack not installed atnpm start
orwebpack-dev-server --hot --progress --colors
, install it globallynpm install -g webpack
- Copy
webpack.config.js
as shown below:
var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: './app/main.js',
output: {
path: __dirname + 'dist',
filename: 'bundle.js',
publicPath: '/'
},
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
},
};
And then change the scripts in package.json
"scripts": {
"start": "webpack-dev-server --hot --progress --colors",
"build": "webpack --progress --colors"
}
if npm start not working because of 'webpack not installed', install webpack globally npm install -g webpack