mkdir koa-react && cd koa-react
npm init -y
koa-react
│
└───build
│
└───server
│ └──server.js
│
└───src
│ └──index.js
│
│ webpack.consfig.js
│ .babelrc
└── package.json
npm install --save-dev webpack
webpack.config.js
var path = require('path');
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'build')
},
module: {
rules: [
{
test: /\.js$/,
use: [
'babel-loader'
]
}
]
}
};
compiler for ES6, JSX, React
npm install --save-dev babel-cli babel-preset-env babel-preset-react
webpack.config.js
module.exports = {
...
module: {
rules: [
{
test: /\.js$/,
use: [
'babel-loader'
]
}
]
}
};
.babelrc
"preset": ["env", "react"]