JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 69928
  • Score
    100M100P100Q152256F
  • License MIT

Register global imports on demand for Vite and Webpack

Package Exports

  • unplugin-remove
  • unplugin-remove/esbuild
  • unplugin-remove/rollup
  • unplugin-remove/types
  • unplugin-remove/vite
  • unplugin-remove/webpack

Readme

unplugin-remove

Auto remove console[log|warn|error|info|debug] and debugger in production

Install

pnpm i unplugin-remove -D

or

yarn add unplugin-remove -D
Vite
// vite.config.ts
import viteRemove from 'unplugin-remove/vite'

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

Example: playground/


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()],
})


Configuration

The following show 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/],
})

License

MIT License © 2022-PRESENT Talljack