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

unplugin-auto-vconsole

v0.0.5

Published

Use vconsole as needed in Vite and Webpack

Downloads

4

Readme

unplugin-auto-vconsole

NPM version

当你希望使用 vconsole,并且希望在生产环境使用,并且还不希望正常用户看到,并且还不希望占用正常用户加载速度或者加载的 js 体积时,你可能用得上

  1. 可以帮助你快捷的引入 vconsole 以方便进行移动端的调试

  2. 当你需要线上环境调试时只需要添加固定参数,即可动态加载并开启 vconsole,eg:http://baidu.com?enable_console=1

  3. 普通用户并不会开启,并且是动态引入,不会给普通用户增加额外的 js 文件体积(vconsole 会被单独打包、但用户默认不会加载)

支持以下配置:

{
  // 生产环境带有哪个参数字段时需要开启 默认为 enable_console
  field?: string;
  // 是否构建阶段 默认为false
  isBuild?: boolean;
  // 是否开启vconsole,有些时候开发环境不需要开启、需要自定判断 默认为 true
  enabled?: boolean;
  // 注入的入口文件 默认为:src/main.ts
  entry?: string | string[];
  // vconsole的配置 默认空
  config?: Object;
}

Install

使用 npm / yarn / pnpm

npm i vconsole
npm i unplugin-auto-vconsole -D
// vite.config.ts
import unpluginVconsole from "unplugin-auto-vconsole/vite";

// 当需要更细致的决定是否需要启动vconsole时
function vconsoleEnabled() {
  if (isBuild) {
    return true;
  } else {
    return true;
  }
}

export default defineConfig({
  plugins: [
    unpluginVconsole({
      field: "enable_console",
      isBuild: command === "build",
      entry: resolve("src/main.ts"),
      enabled: vconsoleEnabled(),
      config: { theme: "dark" },
    }),
  ],
});

Example: playground/

// rollup.config.js
import unpluginVconsole from "unplugin-auto-vconsole/rollup";

export default {
  plugins: [
    unpluginVconsole({
      isBuild: command === "build",
      entry: resolve("src/main.ts"),
    }),
  ],
};

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("unplugin-auto-vconsole/webpack")({
      isBuild: command === "build",
      entry: resolve("src/main.js"),
    }),
  ],
};

// nuxt.config.js
export default {
  buildModules: [
    [
      "unplugin-auto-vconsole/nuxt",
      {
        isBuild: command === "build",
        entry: resolve("src/main.js"),
      },
    ],
  ],
};

This module works for both Nuxt 2 and Nuxt Vite

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require("unplugin-auto-vconsole/webpack")({
        isBuild: command === "build",
        entry: resolve("src/main.js"),
      }),
    ],
  },
};

// esbuild.config.js
import { build } from "esbuild";
import unpluginVconsole from "unplugin-auto-vconsole/esbuild";

build({
  plugins: [
    unpluginVconsole({ isBuild: command === "build", entry: "src/main.js" }),
  ],
});