Skip to content

Repository files navigation

webpack5-cdn-plugin

For webpack4, please refer to webpack4-cdn-plugin.

Docs

Install

npm i webpack5-cdn-plugin -D

Usage

const{ Webpack5CDNPlugin }=require('webpack5-cdn-plugin')letcacheData=null;// webpack configmodule.exports={plugins: [// ...newWebpack5CDNPlugin({keepLocalFiles: false,manifestFilename: 'manifest.json',uploadContent({ file, extname, content }){consthash=md5(content)if(cacheData.has(hash)){returnPromise.resolve(cacheData.get(hash))}// NOTE 需要自己实现上传文件、重试、并发控制// demo: https://gist.github.com/AngusFu/b99b0ffb001b0bf4009d09b5e3b041d6returnuploadTaskManager.upload(content).then(result=>{cacheData.set(hash,result.url)returnresult.url})},before(){cacheData=readCache()},done(){persistCache(cacheData)}})]}

About

Upload your webpack-generated assets to CDN, allowing renaming/rehashing.

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages