一覧へ戻る
Talljack/unplugin-remove(新しいタブで開きます)
主要言語: TypeScript
Auto remove some unused code like console and debugger
- star 数
- 12
- watcher 数
- 1
- fork 数
- 4
- issue 数
- 6
- 最終更新
- 2025/02/25
主要言語: TypeScript
Auto remove some unused code like console and debugger
Auto remove console[log|warn|error|info|debug] and debugger in production mode.
[npm|pnpm] i unplugin-remove -D
or
yarn add unplugin-remove -DExample: playground/
// vite.config.ts import viteRemove from 'unplugin-remove/vite' export default defineConfig({ plugins: [ viteRemove({ /* options */ }), ], })
// rollup.config.js import rollupRemove from 'unplugin-remove/rollup' export default { plugins: [ rollupRemove({ /* options */ }), ], }
// webpack.config.js module.exports = { /* ... */ plugins: [ process.env.MODE === 'production' ? require('unplugin-remove/webpack')({ /* options */ }) : null, ].filter(Boolean), }
// esbuild.config.js import { build } from 'esbuild' import esbuildRemove from 'unplugin-remove/esbuild' build({ plugins: [esbuildRemove()], })
// rspack.config.js const RspackPlugin = require('unplugin-remove/rspack').default module.exports = { plugins: [ new rspack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }), RspackPlugin(), ], }
// rolldown.config.js import { defineConfig } from 'rolldown' import Rolldown from 'unplugin-remove/rolldown' export default defineConfig({ plugins: [ process.env.MODE === 'production' ? Rolldown() : null, ], })
The following shows the default values of the configuration
Remove({ // don't remove console.([log|warn|error|info|debug]) and debugger these module external: [], // remove console type of these module // enum: ['log', 'warn', 'error', 'info', 'debug'] consoleType: ['log'], // filters for transforming targets include: [/\.[jt]sx?$/, /\.vue\??/], exclude: [/node_modules/, /\.git/] })
You can see CHANGELOG here.
MIT License © 2022-PRESENT Talljack