@elenjs/cdn
v0.1.0
Published
ElenJS CDN — compress media and upload to Qiniu / Tencent COS / Aliyun OSS
Downloads
141
Readme
@elenjs/cdn
压缩静态媒体并上传到 CDN。支持七牛、腾讯云 COS、阿里云 OSS(同一时间只用一个 provider)。
环境变量
ELEN_CDN_ACCESS_KEY=
ELEN_CDN_SECRET_KEY=
# 可选
ELEN_CDN_SESSION_TOKEN=
ELEN_CDN_ROOT= # 覆盖 .elencli.cjs 中的 cdn.root.elencli.cjs
module.exports = {
cdn: {
provider: "qiniu", // tencent | aliyun
bucket: "your-bucket",
region: "z2",
domain: "https://cdn.example.com",
root: "site",
sources: [{ from: ".cdn-staging/assets", to: "assets" }],
upload: { overwrite: false, retry: 3, concurrency: 4 },
compress: {
enabled: true,
config: "config/cdn-compress.cjs",
input: "public/assets",
output: ".cdn-staging/assets",
},
},
};API
import { compress, upload } from "@elenjs/cdn";
await compress(); // 或 { mode: "images" | "videos" }
await upload(); // 或 { dryRun: true, force: true }视频压缩需要本机安装 ffmpeg。
