Using react with webpack
$ brew update
$ brew upgrade node
$ npm install -g npm
switch language version to JSX Harmony manually in Preferences | Languages & Frameworks | JavaScript.
$ mkdir webpack-react-action
structure:
.
+-- src
| +-- index.js
+-- webpack.config.js
+-- index.html
+-- package.json
$ npm install webpack --save-dev
$ npm install --save react react-dom babel-loader babel-core babel-preset-react babel-preset-es2015
notes: check if there is 'babel-preset-es2015' in node_modules
webpack.config.js
module.exports = {
entry: './src',
output: {
path: 'builds',
filename: 'bundle.js',
},
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
},
};$ webpack
npm install webpack-dev-server --save-dev
set liveloader publicPath in webpack-config.js:
output: {
path: 'builds',
filename: 'bundle.js',
publicPath: 'builds'
},then run webpack-dev-server, and visit the web-server at http://localhost:8080/webpack-dev-server/
###Useful links:
Getting Started react official site
Copyright (c) 2016 janeluck. Licensed under the MIT license.