Remove console statements from other developers and keep only your own!

As developers, I believe everyone must have encountered a lot of logs in the console, which greatly reduces our development efficiency

Now, I recommend a self-developed Vite plugin that can remove logs not belonging to the user during packaging based …


This content originally appeared on DEV Community and was authored by ctjj

As developers, I believe everyone must have encountered a lot of logs in the console, which greatly reduces our development efficiency

Now, I recommend a self-developed Vite plugin that can remove logs not belonging to the user during packaging based on the git author information

rollup-plugin-remove-others-console:Remove console statements from other developers and keep only your own, making your development more refreshing!

Welcome star and follow me!

install

npm i rollup-plugin-remove-others-console -D

use

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import removeOthersConsole from "rollup-plugin-remove-others-console";

export default defineConfig({
  plugins: [
    removeOthersConsole(),
    // . .. others
  ],
});

warn

1. Not recommended for use in production environments

If packaging only leaves the packager's console.log statement, it may affect other developers' debugging, although this is a bad habit!

You can use the official Vite method to drop all console statements based on the following example.

//vite.config.js
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig({
  plugins: [vue()],
  build: {
    minify: "terser",
    terserOptions: {
      compress: {
        //Remove console in production environment
        drop_console: true,
        drop_debugger: true,
      },
    },
  },
});

2. Please ensure that the files being processed are the most original ones

Due to the strict dependence of the plugin on line interpretation of Git authors, it is necessary to ensure that the plugin is executed before any plugins that may modify the source file.


This content originally appeared on DEV Community and was authored by ctjj


Print Share Comment Cite Upload Translate Updates
APA

ctjj | Sciencx (2025-08-19T06:28:57+00:00) Remove console statements from other developers and keep only your own!. Retrieved from https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/

MLA
" » Remove console statements from other developers and keep only your own!." ctjj | Sciencx - Tuesday August 19, 2025, https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/
HARVARD
ctjj | Sciencx Tuesday August 19, 2025 » Remove console statements from other developers and keep only your own!., viewed ,<https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/>
VANCOUVER
ctjj | Sciencx - » Remove console statements from other developers and keep only your own!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/
CHICAGO
" » Remove console statements from other developers and keep only your own!." ctjj | Sciencx - Accessed . https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/
IEEE
" » Remove console statements from other developers and keep only your own!." ctjj | Sciencx [Online]. Available: https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/. [Accessed: ]
rf:citation
» Remove console statements from other developers and keep only your own! | ctjj | Sciencx | https://www.scien.cx/2025/08/19/remove-console-statements-from-other-developers-and-keep-only-your-own/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.