【发布时间】:2019-08-15 16:41:45
【问题描述】:
我将我的项目从 webpack3.x 升级到 webpack4.28.4,当我运行 webpack 进行生产时,它向我显示错误!
ERROR in ./src/router/_import_production.js 9:11
Module parse failed: Unexpected token (9:11)
You may need an appropriate loader to handle this file type.
| module.exports = function (file) {
| return function () {
> return import("@/views/" + file + ".vue");
| };
| };
@ ./src/router/index.js 8:14-58
@ ./src/main.js
我用happypack来提高编译速度!
const HappyPack = require('happypack')
const os = require('os')
const happyThreadPool = HappyPack.ThreadPool({
size: os.cpus().length
})
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
use: 'happypack/loader?id=babel',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
}
new HappyPack({
id: 'babel',
loaders: [{
loader: 'babel-loader',
query: {
cacheDirectory: true
}
}],
threadPool: happyThreadPool,
verbose: true
})
没有用!谁能解决我的问题?非常感谢!
【问题讨论】: