@pluve/taro-h5-plugin-version-output
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@pluve/taro-h5-plugin-version-output

npm (scoped)

关于

适用于 Taro H5 平台的版本构建插件,在原始构建输出目录下,增加输出以下文件:

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

安装

yarn add @pluve/taro-h5-plugin-version-output -D

使用

// config/prod.ts

import type { UserConfigExport } from "@tarojs/cli";

export default {
  mini: {},
  h5: {},
  plugins: [
    ...(process.env.TARO_ENV === "h5"
      ? [
          [
            "@pluve/taro-h5-plugin-version-output",
            {
              version: "date",
              mainFileName: "index.html",
              mainFilePageTitle: "哥伦布", 
              mainFileTheme: {
                colorPrimary: "#00b578", 
              },
              vconsole: false,
            },
          ],
        ]
      : []),
  ],
} satisfies UserConfigExport;

参数

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>;
  /**
   * 模式
   * - v1.1.0 不再支持 json
   * @default 'json'
   *  - json 生成 version.json, 入口文件通过接口请求 version.json 获取版本号
   */
  mode?: 'json';
  /**
   * 是否注入 vconsole
   * @default false
   */
  vconsole?: boolean;
  /**
   * 自定义入口文件内容
   * @default undefined
   */
  customMainHtml?: (options: {
    mode?: 'json';
    title?: string; // 页面标题,即传入的 mainFilePageTitle
    theme?: Record<string, string>; // 页面主题色,即传入的 mainFileTheme
    vconsole?: boolean;
  }) => string;
}

Package Sidebar

Install

npm i @pluve/taro-h5-plugin-version-output

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

23.5 kB

Total Files

15

Last publish

Collaborators

  • fuqiting
  • zhaoyajie
  • annan1220
  • pengfeng365
  • plutolove
  • vdfor
  • ddg-dany
  • yangwend
  • yaqin8023
  • damonchen
  • lee2545
  • abel0222
  • stevenluo
  • xiongyan
  • deng_cheng