webpack打包node项目[ Module parse failed:]

./node_modules/sockjs-client/dist/sockjs.js.map Module parse failed: Unexpected token (1:10)
.js.map后缀文件没有正确加载

解决方法:
webpack配置文件添加

{
        test: /\.js\.map$/,
        use: {
          loader: 'file-loader'
        },

整体 rules配置如下

 module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        // exclude: "/node_modules/",
        include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
      },
      {
        test: /\.js\.map$/,
        use: {
          loader: 'file-loader'
        },
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('media/[name].[hash:7].[ext]')
        }
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
        }
      }
    ],
    unknownContextCritical: false,
    unknownContextRegExp: /^.\/.*$/
  },

你可能感兴趣的:(JavaScript,nodeJS)