问答详情
源自:2-1 vue-loader+webpack项目配置

vue-loader不好使,npm run build报错

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

https://img2.mukewang.com/5b03e4c90001ae1a07300458.jpg

https://img.mukewang.com/5b03e4c9000113f505830360.jpg

https://img3.mukewang.com/5b03e4ca00019c9e07940469.jpg

https://img.mukewang.com/5b03e4ca000196ec05180460.jpg

不知道怎么解决了,请大家帮帮忙,老师在么?

提问者:3蓑笠翁3 2018-05-22 17:37

个回答

  • qq_肖志瑞_0
    2018-08-08 17:44:38

    const path = require('path')
    const VueLoaderPlugin = require('vue-loader/lib/plugin');
    
    module.exports={
        entry:path.join(__dirname,'src/index.js'),
        output: {
            filename: "bundle.js",
            path: path.join(__dirname,'dist')
        },
        module: {
            rules: [
                {
                    test:/.vue$/,
                    loader: "vue-loader"
                },
                {
                    test:/.css$/,
                    use:[
                        'style-loader',
                        'css-loader'
                    ]
                }
            ]
        },
        plugins: [
            // make sure to include the plugin for the magic
            new VueLoaderPlugin()
        ]
    }

    webpack.config.js  如以上写法,记得下载style-loader、css-loader

  • 幕布斯7532725
    2018-05-24 13:34:40

    由于webpack4版本问题需要修改webpack.config.js配置https://img3.mukewang.com/5b064eed000154d215210942.jpg

  • __张馨__
    2018-05-22 23:53:31

    emmm 虽然我没遇到这错 但是看了一下你的代码 vueloader的版本忒新了 搜了一下你的错误 这个链接里有一个解决办法 你可以试一下 :https://www.imooc.com/article/details/id/29655

    说是最新的vueloader需要在config.js里去设置一下它 

    另附一下我的package.json里的dependencies:

    "dependencies": {

    "cross-env": "^5.1.3",

    "css-loader": "^0.28.7",

    "file-loader": "^1.1.6",

    "html-webpack-plugin": "^2.30.1",

    "style-loader": "^0.19.1",

    "stylus": "^0.54.5",

    "stylus-loader": "^3.0.1",

    "url-loader": "^0.6.2",

    "vue": "^2.5.13",

    "vue-loader": "^13.6.0",

    "vue-template-compiler": "^2.5.13",

    "webpack-dev-server": "^2.11.2"

    },

    "devDependencies": {

    "webpack": "^3.10.0"

    }

    希望能帮到你·········