Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unplugin-remove

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unplugin-remove

Plugin to remove console.xx and debugger for Vite & Webpack & Esbuild & Rollup

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24K
decreased by-42.96%
Maintainers
0
Weekly downloads
 
Created
Source

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
// vite.config.ts
import viteRemove from 'unplugin-remove/vite'

export default defineConfig({
  plugins: [
    viteRemove({ /* options */ }),
  ],
})


Rollup
// rollup.config.js
import rollupRemove from 'unplugin-remove/rollup'

export default {
  plugins: [
    rollupRemove({ /* options */ }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    process.env.MODE === 'production' ? require('unplugin-remove/webpack')({ /* options */ }) : null,
  ].filter(Boolean),
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import esbuildRemove from 'unplugin-remove/esbuild'

build({
  plugins: [esbuildRemove()],
})


Rspack ( ⚠️ experimental)
// 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 ( ⚠️ experimental)
// rolldown.config.js
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({
  // 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/]
})

CHANGELOG

You can see CHANGELOG here.

License

MIT License © 2022-PRESENT Talljack

Keywords

FAQs

Package last updated on 03 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc