我使用的WebPack時收到此錯誤:陣營的WebPack和巴貝爾配置問題
ERROR in ./src/pages/clients/components/ClientProfile.js
Module build failed: SyntaxError: Unexpected token (18:17)
16 | }
17 |
> 18 | handleSubmit = (person) => {
| ^
19 | console.log(person);
20 | };
21 |
我有以下.babelrc
配置
{
"presets" : ["es2015", "stage-3", "react"]
}
這是我的devDependencies
從package.json
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"react-scripts": "0.9.5",
"webpack": "^2.5.1",
"webpack-dev-server": "^2.4.5"
},
"scripts": {
"start": "webpack-dev-server --info",
"build": "webpack",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
和webpack.config.js
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.jsx$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
//include: /flexboxgrid/
}
]
}
我想不通爲什麼它沒有在這句法
handleSubmit = (person) => {
console.log(person);
};
是否有人有想法? 謝謝。