我已经使用 webpack-middleware 设置了 react fullstack 环境。我的代码中有一些 es6 语法,但是在没有构造函数或命名箭头函数的状态下出现错误。例如,我想对react排序表使用语义 UI:https : //react.semantic-ui.com/collections/table#table-example-sortable 编译时出现此错误: 在此处输入图像描述
我认为这是因为我在下面附上了错误的 webpack 设置。
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './client/index.js',
output: {
path: '/',
filename: 'bundle.js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'client/index.html'
})
]
};
.babelrc
{
"presets": ["env", "react", "es2015"]
}