讲师源码中的webpack版本较低,
默认安装的新版本语法已经变化了
试一下下面这个webpack.config.js
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname),
devtool: debug ? "inline-sourcemap" : null,
//入口文件
entry: "./src/js/index.js",
module: {
rules: [
{
test: /\.js?$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
}
]
},
//输出文件
output: {
path: __dirname,
filename: "./src/bundle.js"
}
};