webpack You may need an appropriate loader to handle this file type.

学习webpack+vue时,出现了这个错误。
百度一下这个问题是因为webpack.config.js中没有配置vue-loader。所以在webpack.config.js文件加上

const path = require('path')

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: /.js$/,
                exclude: /(node_modules|bower_components)/,
                use: [
                    {
                        loader: "babel-loader"
                    }
                ]
            }
        ]
    }
}

但是发现依然还有问题,但是问题主要出现在App.vue和index.js中,所以我以为是es6转换错误,就加上了babel-loader中。具体命令:
cnpm i babel-loader babel-core babel-preset-es2015 –save
这时候出现了下述错误
这里写图片描述
这时发现多了个等于号,去掉以后就正常了。

猜你喜欢

转载自blog.csdn.net/babulongbo/article/details/79845439
今日推荐