
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
webpack-cdn-replace-plugin
Advanced tools
webpack插件,用于解决项目文件上传cdn后需要手动替换地址的问题,无任何上传依赖,让用户灵活使用自己想用的cdn上传服务
# npm
npm i -D webpack-cdn-replace-plugin
# yarn
yarn add -D webpack-cdn-replace-plugin
# pnpm
pnpm add -D webpack-cdn-replace-plugin
在你的webpack.config.js文件中:
const { UploadPlugin } = require('webpack-cdn-replace-plugin')
module.exports = {
mode: 'production',
output: {
// 这里的publicPath要为空,不然js文件中的cdn地址会出问题
publicPath: '',
// ...
},
// ...其他webpack配置
plugins: [
// ...其他webpack插件
new UploadPlugin({
uploadFn: async(path, fileName) => {
// 此处调用你要用的cdn上传api,将返回的cdn地址返回
return `http://test.cdn/${fileName}`
}
})
]
}
注意事项:publicPath一定要为空,不然cdn地址替换后会有问题
(path: string, fileName: string) => string | Promise<string>上传cdn的处理函数
默认值:(path, fileName) => fileName
boolean是否启用缓存
默认值:true
object需要上传cdn处理的文件类型
| 参数名 | 类型 | 必选 | 说明 |
|---|---|---|---|
| img | string[] | 否 | 需要上传的图片文件类型 |
| font | string[] | 否 | 需要上传的字体文件类型 |
| css | string[] | 否 | 需要替换图片和字体并上传的css文件类型 |
| js | string[] | 否 | 需要替换图片和字体并上传的js文件类型 |
| html | string[] | 否 | 需要替换css和js的html文件类型 |
默认值:
{
img: ['.png', '.jpg', '.jpeg', '.svg'],
font: ['.ttf', '.otf', '.woff', '.woff2', '.eot'],
css: ['.css'],
js: ['.js'],
html: ['.html']
}
注意事项:html文件不会上传,这里是用于替换其他上传文件的地址
MIT
Copyright (c) 2022 zhusiqing
FAQs
webpack upload and cdn address replace plugin
We found that webpack-cdn-replace-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.