npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

remove-unnecessary-console-vite

v1.0.6

Published

Remove unnecessary console.log in different environment during dev & build with Vite.js

Downloads

1

Readme

🚀 remove-unnecessary-console-vite

Vite.js插件,在生产环境或(和)开发环境,去除掉不必要的console.log()语句,并对有指定标识的语句进行保留。

Remove unnecessary console.log & reserve tagged console in different environment during dev & build with Vite.js

安装 Install

npm i remove-unnecessary-console-vite

引入 Import

// vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {RemoveUnnecessaryConsole} from 'remove-unnecessary-console'

export default defineConfig({
  plugins: [
      RemoveUnnecessaryConsole(),
    // ... others
  ]
});

使用 Use RemoveUnnecessaryConsole()

RemoveUnnecessaryConsole(Num, Env)

| 属性 | 说明 | 类型 |备注| | ---- | ---- | ---- | ---- | | Num | 保留标识 | Number | console.log()中的第一个参数,当第一个参数为Num时,该日志将被保留;不填则全不保留 | Env | 保留环境 | String | "development" 或 "production"。填”development“时,开发环境下仅保留符合保留标识的日志语句,打包后的生产环境所有日志全保留;填”production“时同理相反;不填则不判断环境

示例 Examples

console.log('abc')
console.log(1, 'abc')
console.log(1, 234)
console.log(2, 'def')
console.log(1 + 2)

//①
RemoveUnnecessaryConsole(1)
//开发环境下输出   In development environment
1 'abc'
1 234
//生产环境下输出   In production environment
1 'abc'
1 234

//②
RemoveUnnecessaryConsole(2, 'production')
//开发环境下输出   In development environment
'abc'
1 'abc'
1 234
2 'def'
3
//生产环境下输出   In production environment
2 'def'

//③
RemoveUnnecessaryConsole(3, 'development')
//开发环境下输出   In development environment

//生产环境下输出   In production environment
'abc'
1 'abc'
1 234
2 'def'
3

//④
RemoveUnnecessaryConsole()
//开发环境下输出   In development environment

//生产环境下输出   In production environment