New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@tbmini/tb-assets

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tbmini/tb-assets

tb-assets

latest
npmnpm
Version
2.1.2
Version published
Maintainers
7
Created
Source

id: tb-assets

资源自动上传插件

NPM version

安装

在 Taro 项目根目录下安装

$ npm i @tbmini/tb-assets --save

使用

上传结果统一存放在src/assetlist.json

压缩可能导致图片失真,若出现请单独手动压缩该图片

API

start (Promise)

// 参数
{
  folderName?: string  // 文件夹名 默认 taobaomini
  projectName?: string // 项目名称
  isDev?: boolean  // 是否测试环境  默认 true
  options: {
    min?: boolean
    maxSize?: number
    resPath?: string // 资源路径 默认 ./assets/
    distPath?: string  
    excludeExt?: string[]  // 忽略上传文件后缀名  默认 ['ds_store', 'md', '.DS_Store']
    preDir?: string[] // 预加载目录 默认 []
    jsonPath?: string // assetJSON 路径 默认 ./src/assetList.json'
  }
  cdnPrefix?: string  // cdn前缀 默认 https://yun.duiba.com.cn
  ossConfig: OssConfig
}

上传资源

getPreLoadImg

获取预加载资源列表

// 参数
import * as assetlist from '@/assetlist.json'
assetlist 

// 示例
const imgList =  getPreLoadImg(assetlist)

架构 V2.0.0

文件模块

  • 遍历指定目录,获取文件目录树
  • 文件MD5读取
  • 读取assetJSON
  • 比对assetJSON(1. 文件地址比对 2. 文件md5对比 3. 文件更新时间对比(已废弃))
  • 复写assetJSON

配置模块

  • 资源目录配置
  • 工具配置
  • OSS配置
  • 系统版本校验

上传模块

  • 文件上传

压缩模块

  • 生成临时目录
  • 备份文件
  • 文件过滤
  • PNG压缩
  • 压缩验收

FAQs

Package last updated on 23 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts