__webpack_require__(...) is not a function

使用webpack.DllReferencePlugin打包vue报错

__webpack_require__(...) is not a function

 之后看了官方文档,多写一个context属性,在打包运行就OK了

生成DLL文件的配置文件 webpack.vendor.config.js

const path = require(‘path‘)

const webpack = require(‘webpack‘)

module.exports = {
  mode: ‘development‘,
  entry: {
    vue: [
      ‘vue/dist/vue.js‘,
      ‘vue-router‘
    ]

  },
  output: {
    path: path.resolve(__dirname, ‘../dist‘),
    filename: ‘[name]_dll.js‘,
    library: ‘[name]_dll‘ // 会在全局暴露出vue_dll对象
  },

  plugins: [
    new webpack.DllPlugin({
      context: __dirname,
      name: ‘[name]_dll‘,
      path: path.resolve(__dirname, ‘../dist/manifest.json‘)
    })
  ]
}

webpack打包配置文件 webpack.config.js

插件中

new webpack.DllReferencePlugin({
      context: __dirname,
      manifest: path.resolve(__dirname, ‘../dist/manifest.json‘)
    }),