Skip to content

Remove Console

NPM Version

Automatically removes [log|warn|error|info|debug] and debugger statements from build artifacts in production mode.

Setup

  1. Install the plugin
bash
$ npm add @winner-fed/plugin-remove-console -D
bash
$ yarn add @winner-fed/plugin-remove-console -D
bash
$ pnpm add @winner-fed/plugin-remove-console -D
bash
$ bun add @winner-fed/plugin-remove-console -D
  1. Enable the plugin in the .winrc configuration file
ts
import { defineConfig } from 'win';

export default defineConfig({
  plugins: [require.resolve('@winner-fed/plugin-remove-console')],
  removeConsole: {}
});

Configuration

js
removeConsole({
  // 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/],
})

Released under the MIT License.