为了账号安全,请及时绑定邮箱和手机立即绑定

启动报错You may need an appropriate loader to handle this file type. 都已经加载了

const path = require('path')
const  { VueLoaderPlugin }  = require('vue-loader')
const HTMLPlugin = require('html-webpack-plugin')
const webpack = require('webpack')

const isDev = process.env.NODE_ENV === 'development'

const config = {
    target: 'web',
    entry: path.join(__dirname, 'src/index.js'),
    output: {
        filename: 'bundle.js',
        path: path.join(__dirname, 'dist')
    },
    module:{
        rules: [
            {
              test: /\.vue$/,
              use: [
                  {loader: 'vue-loader'}
              ]
            },

        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: isDev ? '"development"' : '"production"'
            }
        }),
        new HTMLPlugin()

    ]
}

if(isDev){
  config.devServer = {
      port: 8000,
      host: '0.0.0.0',
      overlay: {
          errors: true
      },
      open: true
  }
}

module.export = config


正在回答

3 回答

方法一: 把vue-loader版本替换为14

方法二: 根据vue-loader官方提供的15版本的声明方法,定义plugin。

const VueLoaderPlugin = require('vue-loader/lib/plugin')  
module.exports = {
  module: {
    rules: [
      // ... other rules
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      }
    ]
  },
  plugins: [
    new VueLoaderPlugin()   //15版本需指定plugin
  ]}


4 回复 有任何疑惑可以回复我~
#1

主打情歌

这个是正解
2018-12-05 回复 有任何疑惑可以回复我~

把vue-loader的版本替换成^14.2.0试一下

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

启动报错You may need an appropriate loader to handle this file type. 都已经加载了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信