https://github.com/xiaoxian521/vite-plugin-remove-console
Vite plugin that remove all the specified console types in the production environment
https://github.com/xiaoxian521/vite-plugin-remove-console
Last synced: 15 days ago
JSON representation
Vite plugin that remove all the specified console types in the production environment
- Host: GitHub
- URL: https://github.com/xiaoxian521/vite-plugin-remove-console
- Owner: xiaoxian521
- License: mit
- Created: 2022-01-06T14:05:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T07:20:01.000Z (over 1 year ago)
- Last Synced: 2024-10-14T09:43:40.934Z (6 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.24 MB
- Stars: 158
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-vite - vite-plugin-remove-console - A vite plugin that deletes console.log in the production environment. (Plugins / Framework-agnostic Plugins)
- awesome-vite - vite-plugin-remove-console - A vite plugin that deletes console.log in the production environment. (Plugins / Framework-agnostic Plugins)
README
vite-plugin-remove-console
A vite plugin that remove all the specified console types in the production environment
English | [็ฎไฝไธญๆ](./README.zh_CN.md)
## ๐ Features
#### โก **High precision, zero intrusion**: Accurately and completely remove the `console` type specified in the code, and currently support the removal of file formats `.js`ใ`.ts`ใ`.jsx`ใ`.tsx`ใ`.vue`ใ`.svelte`
#### ๐งช **Perfect example**: Currently we have added `nuxt3`ใ`preact-js`ใ`preact-ts`ใ`react-js`ใ`react-ts`ใ`solid-js`ใ `solid-ts`ใ `svelte-js`ใ`svelte-ts`ใ`vue-js`ใ`vue-ts` examples to the [playgrounds](https://github.com/xiaoxian521/vite-plugin-remove-console/tree/main/playgrounds) folder, zero usage cost
#### ๐ฆพ **Configurable**:
| configuration | must | meaning | type | example |
| :-------------- | :--- | :----------------------------------------------------------- | :-------------- | :----------------------------------------------------------- |
| `external` | No | supported to pass external to represent certain files not to delete the specified `console` type of operation | `Array` | `removeConsole({external: ["src/assets/iconfont/iconfont.js",...]})` |
| `includes` | No | supports passing `includes` to specify the type of `console` that needs to be removed๏ผIf `includes` is not passed, `console.log` will be removed by default | `Array` | `removeConsole({ includes: ["log", "warn", "error", "info", ...] })` |
| `externalValue` | No | some `console` statements are reserved, if there is an incoming `externalValue` value in the `value` of the `console`, the `console ` will be preserved | `Array` | `removeConsole({ externalValue: ["่ฟไธชไธๅ ", "noRemove", ...] })` |
| `custom` | No | Completely customize the statements that need to be removed, which will overwrite `includes` | `Array` | `removeConsole({ custom: ["console.log()", "console.warn()", "debugger", ...] })` |## ๐ฆ install
```bash
# npm
npm install vite-plugin-remove-console -D# or yarn
yarn add vite-plugin-remove-console -D# or pnpm
pnpm add vite-plugin-remove-console -D
```## ๐ Usage
```ts
// vite.config.tsimport { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import removeConsole from "vite-plugin-remove-console";// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), removeConsole()]
});
```Refer to [more examples](https://github.com/xiaoxian521/vite-plugin-remove-console/tree/main/playgrounds)
## License
[MIT ยฉ 2022-present, xiaoxian521](./LICENSE)