unplugin-remove
Auto remove console[log|warn|error|info|debug]
and debugger
in production mode.
Install
[npm|pnpm] i unplugin-remove -D
or
yarn add unplugin-remove -D
Demo
Example: playground/
Vite
import viteRemove from 'unplugin-remove/vite'
export default defineConfig({
plugins: [
viteRemove({ }),
],
})
Rollup
import rollupRemove from 'unplugin-remove/rollup'
export default {
plugins: [
rollupRemove({ }),
],
}
Webpack
module.exports = {
plugins: [
process.env.MODE === 'production' ? require('unplugin-remove/webpack')({ }) : null,
].filter(Boolean),
}
esbuild
import { build } from 'esbuild'
import esbuildRemove from 'unplugin-remove/esbuild'
build({
plugins: [esbuildRemove()],
})
Rspack (
⚠️
experimental)
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
(
⚠️
experimental)
import { defineConfig } from 'rolldown'
import Rolldown from 'unplugin-remove/rolldown'
export default defineConfig({
plugins: [
process.env.MODE === 'production' ? Rolldown() : null,
],
})
Configuration
The following shows the default values of the configuration
Remove({
external: [],
consoleType: ['log'],
include: [/\.[jt]sx?$/, /\.vue\??/],
exclude: [/node_modules/, /\.git/]
})
CHANGELOG
You can see CHANGELOG here.
License
MIT License © 2022-PRESENT Talljack