mkdir test1 # dir path must not contine 'react', will cause error
npm init
set info
npm install --save react react-dom redux react-redux immutable
npm install --save-dev webpack babel-loader babel-preset-es2015 babel-preset-react
set webpack, create webpack.config.js
module.exports = {
entry: './src/app.js',
output: {
path: __dirname,
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: { presets: [ 'es2015', 'react' ] }
}
]
}
};
extend our package.json by adding an npm script to compile our code with source maps
"script": {
"build": "webpack --debug"
"watch": "webpack --watch"
}
We’ll need to run npm run build each time we want to compile our code.