4.0.0 • Published 1 month ago

@fox-js/vite-plugin-encrypt v4.0.0

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

Fox vite-plugin-encrypt

文件加密插件

Install

NPM

npm i @fox-js/vite-plugin-encrypt -D

YARN

yarn add @fox-js/vite-plugin-encrypt -D

PNPM

pnpm add @fox-js/vite-plugin-encrypt -D

使用指南

import { UserConfigExport, ConfigEnv, loadEnv } from 'vite'
import encrypt from '@fox-js/vite-plugin-encrypt'
import { join } from 'path'

export default ({ command, mode }: ConfigEnv): UserConfigExport => {
  return {
    plugins: [
       encrypt({
        key: '******************',
        target: join(__dirname, '../dist'),
        accept: (path: string) => {
          return true
        }
      }),
    ]
  }
}

参数

/**
 * 是否接受文件
 */
export declare interface Accept {
    (path: string): boolean;
}

/**
 * 参数
 */
export declare interface EncryptOptions {
    key: string;
    target: string;
    accept: Accept;
}

/**
 * encrypt plugin工厂
 * @param options
 * @returns
 */
declare function encryptPlugin(options: EncryptOptions): Plugin;