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

webpack-qiniu-cdn-plugin

v1.1.2

Published

A webpack plugin for upload webpack assets to qiniu CDN

Downloads

7

Readme

webpack-qiniu-cdn-plugin

将webpack输出的资源上传至七牛对象存储(kodo),并修改资源访问链接为指定的CDN链接

Usage

webpack.config.js

const QiniuCDNPlugin = require('webpack-qiniu-cdn-plugin');
module.exports = {
  plugins: [
    new QiniuCDNPlugin({
      accessKey: '__access_ket__',
      secretKey: '__secret_key__',
      cdnHost: '__host__',
      bucket: '__bucket__',
      dir: 'access',
      exclude: /\.html$/,
      expire: {
        versions: 1,
        time: 60
      },
      refresh: true,
      prefetch: true,
      dry: true
    });
  ]
}

Options

字段名 | 类型 | 描述 | 默认值 -- | -- | -- | -- accessKey | string | 七牛accessKey | - secretKey | string | 七牛secretKey | - bucket | string | 对象存储bucket | - cdnHost | string | 用于访问DNS资源的域名 | - dir | string | 存储文件时使用的文件夹前缀,不包括末尾的/ | '' logFile | string | 版本记录文件的文件名 | 'upload-log.json' expire | Expire | false | 版本过期策略,false表示不过期 | false exclude | RegExp | function | 选择哪些文件不需要上传,当值为函数是接收文件路径作为参数,返回true表示排除该文件 | () => false refresh | boolean | 覆盖上传是否刷新CDN缓存 | false prefetch | boolean | 上传后是否执行CDN预取 | false silent | boolean | 安静模式 | false dry | boolean | 不执行实际的上传删除操作,用于调试 | false

加粗表示必填项

过期版本中不被使用的文件会被插件从存储空间中删除

expire选项包含两个成员

字段名 | 类型 | 描述 -- | -- | -- time | number | 过期时间(秒) versions | number | 需要保留的版本数

过期时间是指本次构建时间 - 对应版本构建时间,即版本的存活时间。 保留版本数是指需要保留的先前版本的数量,不包括当前版本。

同时满足两个条件的会被认为是过期版本(当前时间距离记录的构建时间大于过期时间,并且不在保留版本范围内) 省略某一条件表示不校验该条件

UploadStatus

silent不为true时会在控制台打印下列统计信息:

名称 | 描述 -- | -- remote | 存储空间中现有的文件列表 exclude | 被exclude选项排除的文件 overwrite | 覆盖性上传的文件 omit | 忽略上传的文件(存储空间中已存在名称相同且hash相同的文件) upload | 新上传的文件 clean | 被回收的文件

Tips

  • 不需要在webpack额外设置output.publicPath,插件会根据cdnHostdir自动设置
  • 记录文件的保存路径是${cdnHost}/${dir}/${logFile}
  • 回收操作只会清除logFile中有记录的条目,所以更改prefix或是logFile选项后需要手动清除旧的资源
  • CDN refresh操作只会刷新被覆盖更新的资源
  • CDN prefetch操作只会预取新上传的资源