Nupolyon
從 https://cdnjs.cloudflare.com/polyfill/ 自動注入 polyfill
⚠️ 警告
請勿使用此模組,polyfill.io 已被報告注入惡意程式碼。我們暫時將 URL 更改為 Cloudflare 的映象。
https://sansec.io/research/polyfill-supply-chain-attack
https://www.theregister.com/2024/06/25/polyfillio_china_crisis/
https://www.scmagazine.com/brief/over-100k-sites-hit-by-polyfill-io-supply-chain-attack
功能
- ✅ 基於 browserslist 目標自動檢測
- ✅ 使用 cloudflare polyfill CDN、自定義 CDN 或自託管
有關詳細功能說明,請參見此處:#58 (評論)
快速設定
- 將
nupolyon
依賴新增到您的專案中
npx nuxi@latest module add nupolyon
- 將
nupolyon
新增到nuxt.config.ts
的modules
部分
export default defineNuxtConfig({
modules: [
'nupolyon'
]
})
就這樣!您現在可以在 Nuxt 應用程式中使用 Nupolyon 了 ✨
配置
export default defineNuxtConfig({
modules: [
'nupolyon'
],
nupolyon: {
// change host
host: 'http://my-own-cdn.com/polyfill.min.js'
// or enable self-host mode
host: 'selfhost'
// customize browserslist's target
target: 'defaults'
},
})
開發
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release
許可證
本專案根據 MIT 許可釋出,詳見 LICENSE。