Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
high-cdn-webpack-plugin
Advanced tools
high-cdn-webpack-plugin是Webpack一款插件,用来在index.html引用的CDN服务器宕机后自动替换CDN地址,实现CDN高可用的服务状态,需要配合html-webpack-plugin生成的模板html动态注入。
实现效果:
使用前:
使用后:
npm install high-cdn-webpack-plugin --save
确定模板文件中存在标签,否则插件无法正常找到脚本插入点:
<!DOCTYPE html>
<html lang="en">
<head> <!-- 存在head标签才能使用 -->
<meta charset="UTF-8">
<title>hello world</title>
</head>
<body>
</body>
</html>
引入插件,并实例化:
// webpack.config.js
const HighCdnWebpackPlugin = require("high-cdn-webpack-plugin");
module.exports = {
// ... 省略其他配置
plugins: [
// ... 省略其他插件
new HighCdnWebpackPlugin({
template: 'index.html',
js: [
{
external: {
'vue': 'Vue'
},
path: 'https://cdn.staticfile.org/vue/2.5.16/vue.min.js',
replacementPath: '/vue/3.0.11/vue.cjs.min.js'
},
{
external: {
'vue-router': 'VueRouter',
},
path: 'https://cdn.staticfile.org/vue-router/3.0.1/vue-router2.min.js',
replacementPath: '/vue-router/4.0.6/vue-router.cjs.js'
},
],
css: ['https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/theme-chalk/index.min.css']
})
]
}
// vue.config.js
const HighCdnWebpackPlugin = require("high-cdn-webpack-plugin");
module.exports = {
// ... 省略其他配置
configureWebpack: {
plugins: [
// ... 省略其他插件
new HighCdnWebpackPlugin()
]
}
}
属性 | 类型 | 必填 | 说明 |
---|---|---|---|
template | String | N | 打包目录下模板文件名称,默认为index.html |
css | Array | N | Css cdn地址,css暂不支持高可用 |
js | Array | Y | Js文件cdn地址,格式如下方 |
{
external: { // CDN module export 声明
'vue': 'Vue'
},
path: 'https://cdn.staticfile.org/vue/2.5.16/vue.min.js', // CDN地址
replacementPath: 'https://cdn.bootcdn.net/ajax/libs/vue/3.0.11/vue.cjs.min.js' // path CDN失效后,将用此个地方的地址代替,一般使用自己服务器上的静态文件地址
}
FAQs
a high availability cdn plugin
The npm package high-cdn-webpack-plugin receives a total of 1 weekly downloads. As such, high-cdn-webpack-plugin popularity was classified as not popular.
We found that high-cdn-webpack-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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.