Arch4Arts
Arch4Arts

Reputation: 133

How to remove comments in chunk-vendors.js

a little strange question, but how to remove comments from the file chunk-vendors.js? I mean, there are automatically placed licenses and other information about plugins, including the vue, vuex, vue-router.

Is there any parameter responsible for this? I’m tired of removing these lines manually after each build

I use vue-cli

Upvotes: 7

Views: 5426

Answers (1)

tony19
tony19

Reputation: 138526

Assuming Vue CLI 3 or newer, this is handled by the minimizer's (terser) output options. Specifically, set output.comments=false to exclude comments from the minified output.

Edit vue.config.js to include:

module.exports = {
  chainWebpack: config => {
    config.optimization.minimizer('terser').tap((args) => {
      args[0].terserOptions.output = {
        ...args[0].terserOptions.output,
        comments: false  // exclude all comments from output
      }
      return args
    })
  }
}

Upvotes: 17

Related Questions