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

@pluve/vite-plugin-version-output

v1.1.0

Published

The version output plugin for vite

Downloads

7

Readme

@pluve/vite-plugin-version-output

npm (scoped)

关于

版本构建插件,在原始构建输出目录下,增加输出以下文件:

  • index-{version}.html - 版本文件,内容同 index.html
  • version.json - 记录最新版本号
  • 对外入口文件(默认为 main.html)- 当访问入口文件时,从 version.json 获取最新版本号, 跳转到对应的版本号文件路径(即 index-{version}.html

安装

yarn add @pluve/vite-plugin-version-output -D

使用

import { defineConfig } from 'vite';
import versionOutput from '@pluve/vite-plugin-version-output';

export default defineConfig({
  plugins: [
    versionOutput({
      version: 'date',
      mainFileName: 'index.html',
      mainFilePageTitle: '哥伦布',
      mainFileTheme: {
        colorPrimary: '#00b578',
      },
      vconsole: false,
    }),
  ],
})

参数

interface Options {
  export interface Options {
  /**
   * 版本号
   *  - date 取当前构建时间 YYYYMMDDHHmm
   *  - 其他输入为自定义版本号(自定义版本号必须数字或小写字母构成)
   *  - false 或 空字符串 此插件不启用
   * @default 'date'
   */
  version?: 'date' | false | string;
  /**
   * 入口文件名称
   * @default 'main.html'
   */
  mainFileName?: string;
  /**
   * 入口文件页面标题
   * @default undefined
   */
  mainFilePageTitle?: string;
  /**
   * 入口文件主题色
   * @default { colorPrimary: '#00b578' }
   */
  mainFileTheme?: Record<string, string>;
  /**
   * 模式
   * - v0.0.4 新增
   * - v1.1.0 mode 不再支持 'js' 可选项
   * @default 'json'
   *  - json 生成 version.json, 入口文件通过接口请求 version.json 获取版本号
   */
  mode?: 'json';
  /**
   * 是否注入 vconsole
   * - v0.0.7 新增
   * @default false
   */
  vconsole?: boolean;
  /**
   * 自定义入口文件内容
   * - v1.0.0 新增
   * @default undefined
   */
  customMainHtml?: (options: {
    mode?: 'json';
    title?: string; // 页面标题,即传入的 mainFilePageTitle
    theme?: Record<string, string>; // 页面主题色,即传入的 mainFileTheme
    vconsole?: boolean;
  }) => string;
}