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.

Vite: terser options for drop_console do not work

See original GitHub issue

What happened?

As defined in the specs, the terserOptions for dropping console logs do no work in vite builds:

minify: 'terser',
extendViteConf (viteConf) {
        viteConf.terserOptions = {
          compress: {
            drop_console: true,
            drop_debugger: true
         }
        }
      },

What did you expect to happen?

Expected console logs to be dropped from build.

Reproduction URL

https://stackblitz.com/edit/quasarframework-cxqksw?file=quasar.config.js

How to reproduce?

  1. quasar build

Examine output, console logs not removed

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

Chrome

Quasar info output

Operating System - Darwin(21.5.0) - darwin/x64
NodeJs - 16.15.1

Global packages
  NPM - 8.13.2
  yarn - 1.22.19
  @quasar/cli - 1.3.2
  @quasar/icongenie - 2.3.0
  cordova - Not installed

Important local packages
  quasar - 2.7.5 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-vite - 1.0.5 -- Quasar Framework App CLI with Vite
  @quasar/extras - 1.14.2 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.2.37 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.0.16
  pinia - Not installed
  vuex - 4.0.2 -- state management for Vue.js
  vite - 2.9.13 -- Native-ESM powered web dev build tool
  eslint - 8.19.0 -- An AST-based pattern checker for JavaScript.
  electron - Not installed
  electron-packager - Not installed
  electron-builder - Not installed
  register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Quasar App Extensions
  @quasar/quasar-app-extension-testing - 2.0.4 -- A Quasar App Extension for managing Test Harnesses
  @quasar/quasar-app-extension-testing-e2e-cypress - 4.1.4 -- A Quasar App Extension for Cypress e2e

Relevant log output

No response

Additional context

esbuild has its own problems (drops css the app depends on) which is why I need to use terser. Terser does not drop the css rules I need, but it does not allow dropping of console logs (despite what the docs say). This all works fine in webpack btw.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ssuesscommented, Jul 12, 2022

@MilosPaunovic Actually no, the solution is for esbuild. There is still no solution if one should choose terser.

0reactions
snowwolfjaycommented, Jul 13, 2022

https://stackblitz.com/edit/quasarframework-paqbhe

your config not right, vite config guid terseroptions is a sub config under build key, try the online build test. and viteConf.minify = ‘terser’ should be viteConf.build.minify = ‘terser’

 viteConf.build.terserOptions = viteConf.build.terserOptions || {};
 viteConf.build.terserOptions = {
          ...viteConf.build.terserOptions,
          compress: {
            ...viteConf.build.terserOptions.compress,
            drop_console: true,
          },
        };
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I drop console in a VITE2 project? - Stack Overflow
I googled and found the terserOptions, however, it didn't work. So I just create a blank template from the offical site with the...
Read more >
Build Options - Vite
If the build.minify option is 'terser' , 'esnext' will be forced down to 'es2021' . In other cases, it will perform no transpilation...
Read more >
Dropping Webpack for Vite Part 1 - Jeff Knox
The build time is not the full Netlify deploy time which includes ... looked like a great option with no bundling required for...
Read more >
santree/vite - Gitee
Vite assumes you are targeting modern browsers and by default only transpiles your code to es2019 during build (so that optional chaining can...
Read more >
Untitled
Conclusion. rollup-plugin-terser is an open source tool with 463 GitHub stars and 39 ... Use the minify: true option, it only works for...
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