我刚接触Vue和Webpack,所以希望这不是一个非常愚蠢的问题。
尝试构建文件时,Babel似乎无法识别ES6语法:
ERROR in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/FullPage.vue
Module build failed: SyntaxError: Unexpected token (67:10)
65 | events: constants.EVENTS.reduce((eventsHandlers, event) => {
66 | return {
> 67 | ...eventsHandlers,
| ^
68 |
69 | [event]: (...args) => {
70 | this.emitEvent(event, args);
我的开发依赖项:
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
}
我在webpack文件中的模块规则包括:
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
您可以检查整个Webpack文件here