vite-plugin-strip

Remove or strip specific code from your JavaScript or TypeScript.
4,734 1
Install
npm install vite-plugin-strip
Latest Version:1.1.0
License:MIT
Last Updated:Feb 5, 2024
Links: GitHub  ·  npm
Maintainer: yaro852373851

vite-plugin-strip

📖 Introduction

vite-plugin-strip is a Vite plugin that allows you to remove or strip specific code from your JavaScript or TypeScript project during the build process. It provides an easy and efficient way to remove unnecessary code, such as console.log statements or debug code, before deploying your application.

📦 Installation


# vite-plugin-strip 

pnpm install vite-plugin-strip -D
# OR
npm install vite-plugin-strip -D

🦄 Usage

Configuration Vite

// devBlock:start
console.log('start')
// devBlock:end

/* devBlock:start */
console.log('start')
/* devBlock:end */

// for Vue3

import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Strip from 'vite-plugin-strip'

export default defineConfig({
  plugins: [Vue(), Strip({
    domainList: ['xxx.com']
  })],
})

Options

interface VitePluginStripOptions {
  /**
   * 是否启用插件
   */
  enabled?: boolean

  /**
   * 判断 当前的域名 是包含在 domainList 中,则禁用console.log
   */
  domainList?: string[]

  /**
   * 开始标记
   * @default 'devBlock:start'
   * @example
   * ```ts
   * // devBlock:start
   * console.log('start')
   * // devBlock:end
   * ```
   */
  start?: string

  /** 
   * 结束标记
   * @default 'devBlock:end'
   */
  end?: string
  enable?: () => void
}

Related Packages

@mars-tech/vite-debug-plugin

Vite plugin exposing a global $debug function in dev that mirrors output to the...

1,430
uni-debug-toolbox

On-device debug toolbox for uni-app Vue 3

178 0
vite-plugin-vue-dev-locator

jump to local IDE source code while click the element of browser automatically.

31,227
vite-plugin-vue-inspector-ai

Vue Inspector with enhanced features - supports end line and clipboard copy

4,374 0
vite-plugin-click-to-vue-component

jump to local IDE source code while click the element of browser automatically.

685

Version History

Version Released License
1.1.0 MIT
1.0.2 MIT
1.0.1 MIT