Quasar Framework 配置移出console.log

 

https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build

quasar.conf.js:

module.exports = function (ctx) {
  return {
  ...
    build: {
    ...
      uglifyOptions: {
        compress: { drop_console: true }
      }
    },
  }
}

The above will result in configuring terser plugin with the following:

          terserOptions: {
            compress: {
            ...
              drop_console: true
            },

(https://github.com/terser/terser#compress-options)

(you can see the generated config with quasar inspect -c build -p optimization.minimizer)

You still also need to remove the eslint rule to avoid build errors, see https://github.com/quasarframework/quasar/issues/5529

Note: If you want instead to configure webpack directly use:

quasar.conf.js:

module.exports = function (ctx) {
  return {
  ...
    build: {
    ...
      chainWebpack (chain) {
        chain.optimization.minimizer('js').tap(args => {
          args[0].terserOptions.compress.drop_console = true
          return args
        })
      }
    },
  }
}

It will do the same as above.

See https://quasar.dev/quasar-cli/cli-documentation/handling-webpack

and https://github.com/neutrinojs/webpack-chain#config-optimization-minimizers-modify-arguments

https://github.com/quasarframework/quasar/blob/dev/app/lib/webpack/create-chain.js#L315

posted on 2022-04-03 02:02  zhangzongshan  阅读(169)  评论(0编辑  收藏  举报

导航