Skip to content

The plugin is used to clear all console output in the production environment

License

Notifications You must be signed in to change notification settings

flingyp/vite-plugin-clear-console

Repository files navigation

vite-plugin-clear-console

The plugin is used to clear all console output in the production environment
NPM version NPM version NPM version

🚀 Introduce

The advantage of using this plugin is that there is no need to delete the relevant console of the source file for debugging in the development environment and elimination in the production environment.

📦 Installation

npm install vite-plugin-clear-console -D

yarn add vite-plugin-clear-console -D

pnpm install vite-plugin-clear-console -D

🎉 Usage

import { defineConfig } from 'vite'
import clearConsole from 'vite-plugin-clear-console'

export default defineConfig({
  plugins: [
    {
      ...clearConsole(),
      apply: 'build', // build environment
    },
  ],
})

👏 Options

  1. exclude

You can specify excluded files so that the console corresponding to the source file is not deleted

Example:

import { defineConfig } from 'vite'
import clearConsole from 'vite-plugin-clear-console'

export default defineConfig({
  plugins: [
    {
      ...clearConsole({ exclude: ['./src/main.ts', './views/login.tsx'] }),
      apply: 'build',
    },
  ],
})
  1. suffix

Source file suffix that should be filtered. Its default value is ['js', 'ts', 'tsx', 'jsx', 'vue'], and you can overwrite the option.

Example:

import { defineConfig } from 'vite'
import clearConsole from 'vite-plugin-clear-console'

export default defineConfig({
  plugins: [
    {
      ...clearConsole({ suffix: ['js', 'ts', 'vue'] }),
      apply: 'build',
    },
  ],
})
  1. inject

You can add console to your final product. And finally added to the entry file of the project for simple description.

example:www.baidu.com

For instance, you can view the playground.

License

The Vite plugin is open-sourced software licensed under the MIT license.

About

The plugin is used to clear all console output in the production environment

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published