question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

uglifyOptions config is not working in webpack 5

See original GitHub issue

Describe the bug In quasar.conf.js file, I use uglifyOptions to drop console log in production, but since I upgraded to webpack 5, it’s no longer working. There’s my config:

build: {
      scopeHoisting: true,
      vueRouterMode: 'history', // available values: 'hash', 'history'
      showProgress: true,
      gzip: false,
      analyze: false,
      // drop console
      uglifyOptions: {
        compress: { pure_funcs: ['console.log'] }
      },
      extendWebpack (cfg) {
        if (cfg.output) {
          cfg.plugins.push(new CopyWebpackPlugin({
            patterns: [{ from: './wTFg6cBrWb.txt', to: cfg.output.path }, { from: './MP_verify_2fJZiZCzjBnVRnZ2.txt', to: cfg.output.path }]
          }))
        }
      },
      chainWebpack (chain) {
        const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
        chain.plugin('node-polyfill').use(nodePolyfillWebpackPlugin)
      }
    },

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
goforucommented, Nov 3, 2021

Here is my solution, hoping to help people needed. Adding excludeAliases to tell Ployfill ignore console.

const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
chain.plugin('node-polyfill').use(nodePolyfillWebpackPlugin, [{ excludeAliases: ['console'] }])
0reactions
goforucommented, Nov 3, 2021

THANKS for your detailed information, appreciated!!! After hours of debugging, I finally found where the problem is.

My project has the dependency node-polyfill-webpack-plugin for crypto lib. When I run quasar build, it will firstly transcript console to random letter such as

Y.info('drop test')

In that case, Uglify can’t find console key words to drop, as a result issue remains.

So my following question is **How can I set minimizer work before node-polyfill-webpack-plugin **

Read more comments on GitHub >

github_iconTop Results From Across the Web

UglifyJS and webpack v5 - Stack Overflow
It appears that UglifyJS does not work with webpack v5. Is there an alternative? We need something that works with babel-loader. Thanks. webpack...
Read more >
UglifyjsWebpackPlugin | webpack
This plugin uses uglify-js to minify your JavaScript. Requirements. This module requires a minimum of Node v6.9.0 and Webpack v4.0.0. Getting Started.
Read more >
Top 5 webpack Code Examples - Snyk
Learn more about how to use webpack, based on webpack code examples created from the most popular ways it is used in public...
Read more >
uglifyjs-webpack-plugin - npm
Start using uglifyjs-webpack-plugin in your project by running `npm ... UglifyJsPlugin is scheduled for webpack v4.0.0 ... webpack.config.js.
Read more >
webpack/webpack - Gitter
Webpack has been initialised using a configuration object that does not match the ... The problem is that i am using knex.js and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found