配置
我在我的symfony项目中使用webpack-encore来编译我的reactjs项目。到目前为止,我已经使用了在启用它时应该开箱即用的基本设置:webpack.config.js
// webpack.config.js
// ...
Encore
// ...
.enableReactPreset()
;
我试过的:
我继续添加 babel 配置(我认为不需要),希望它能解决问题,但它没有:
.configureBabel(function(babelConfig) {
// add additional presets
babelConfig.presets.push('es2017');
})
代码示例:
这是应该工作的示例,但它不会编译并引发以下错误:
语法错误:意外的令牌
import React, {Component} from 'react';
//This works
const someExteriorHandler = () => {};
export default class Example extends Component {
//error bad syntax, points specifically at the equal sign.
someHandler = () => {
}
render(){return(<h1>This is a test</h1>)}
}
问题
如何让webpack-encore中的 babel 编译器编译javascript类中的箭头函数?