Remove console statements from other developers and keep only your own, making your development more refreshing
npm i rollup-plugin-remove-others-console -D
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import removeOthersConsole from "rollup-plugin-remove-others-console";
export default defineConfig({
plugins: [
removeOthersConsole(),
// . .. others
],
});
####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,
},
},
},
});
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.
MIT