如何在 vue.congif.js 中忽略 Vue CLI3 上的插件

Va5*_*a54 8 vue.js vue-cli

我正在使用 Vue cli3,并且想忽略带有 webpack 的 moment.js 插件。这是规则,但在 vue.confing.js 上,无论我如何更改它都会出错。

  plugins: [
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
    ], 
Run Code Online (Sandbox Code Playgroud)

Phi*_*hil 17

您似乎正在尝试使用已弃用的构造函数。试试这个,不要忘记导入webpack到脚本中......

const webpack = require('webpack')

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.IgnorePlugin({
        resourceRegExp: /^\.\/locale$/,
        contextRegExp: /moment$/
      })
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)