提示:您可能需要适当的加载程序来处理此文件类型

时间:2019-03-25 12:29:48

标签: vue.js webpack

我将项目从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
})

它没有用!有人能解决我的问题吗?谢谢!

1 个答案:

答案 0 :(得分:0)

_import_production.js修改此文件

siteCount