Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore plugin on Vue CLI3 in vue.congif.js

Tags:

vue.js

vue-cli

I'm using Vue cli3, and want to ignore moment.js plugin with webpack. This is the rule, but on vue.confing.js it gives an error no matter how I change it.

  plugins: [
        new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
    ], 
like image 532
Va54 Avatar asked Feb 10 '19 16:02

Va54


2 Answers

You appear to be trying to use the deprecated constructor. Try this instead and don't forget to import webpack into the script...

const webpack = require('webpack')

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.IgnorePlugin({
        resourceRegExp: /^\.\/locale$/,
        contextRegExp: /moment$/
      })
    ]
  }
}
like image 98
Phil Avatar answered Nov 14 '22 06:11

Phil


If you want to remove all of moment and not just the locales as the OP seemed to want, here is the required configuration:

const webpack = require('webpack');

module.exports = {
    configureWebpack: {
        plugins: [
            new webpack.IgnorePlugin({
                resourceRegExp: /moment$/
            }),
        ]
    }
};
like image 30
James Avatar answered Nov 14 '22 06:11

James