
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.
zin-plugin-preload
Advanced tools
Vite插件,为Vue3项目提供全面的资源连接预加载功能,优化应用性能和加载速度。
使用npm安装:
npm install zin-plugin-preload --save-dev
使用yarn安装:
yarn add zin-plugin-preload -D
使用pnpm安装:
pnpm add zin-plugin-preload -D
在Vite配置文件中添加插件:
// vite.config.js
import { defineConfig } from 'vite'
import VuePreloadPlugin from 'zin-plugin-preload'
export default defineConfig({
plugins: [
VuePreloadPlugin() // 使用默认配置
]
})
// vite.config.js
import { defineConfig } from 'vite'
import VuePreloadPlugin from 'zin-plugin-preload'
export default defineConfig({
plugins: [
VuePreloadPlugin({
// 自动扫描设置
autoScan: true,
scanFilePatterns: ['**/*.vue', '**/*.js', '**/*.ts'],
// DNS预解析配置
dnsPrefetch: {
enabled: true,
domains: [
'https://api.example.com',
'https://cdn.example.com'
],
excludeDomains: [
'https://low-priority.example.com'
]
},
// 预连接配置
preconnect: {
enabled: true,
domains: [
'https://api.example.com',
'https://cdn.example.com'
],
excludeDomains: []
},
// 资源预加载配置
preload: {
enabled: true,
resources: [
'https://cdn.example.com/fonts/main.woff2',
'https://cdn.example.com/images/logo.png'
],
excludeResources: [],
types: ['font', 'image', 'script', 'style']
},
// 资源预取配置
prefetch: {
enabled: true,
resources: [
'https://cdn.example.com/js/lazy-module.js'
],
excludeResources: [],
types: ['font', 'image', 'script', 'style'],
limit: 10 // 限制预取资源数量
},
// 调试模式
debug: false
})
]
})
对于一般的Vue3项目,推荐以下配置:
VuePreloadPlugin({
dnsPrefetch: {
enabled: true,
// 添加常用的第三方域名
domains: [
'https://fonts.googleapis.com',
'https://fonts.gstatic.com',
'https://cdn.jsdelivr.net'
]
},
preconnect: {
enabled: true,
// 仅对核心API域名进行预连接
domains: [
'https://api.example.com'
]
},
preload: {
enabled: true,
// 预加载关键字体和样式
resources: [
'/fonts/main.woff2'
],
types: ['font']
},
prefetch: {
enabled: true,
limit: 5 // 限制预取资源数量
}
})
检查以下几点:
可以通过浏览器开发者工具的Network面板查看:
MIT License
FAQs
Vite插件,为Vue3项目提供资源连接预加载功能,包括DNS预解析、预连接、预加载和预取
We found that zin-plugin-preload demonstrated a healthy version release cadence and project activity because the last version was released less than 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.