通过 100+ 技巧集合学习 Nuxt!

nupolyon

将来自 polyfill.io 的 polyfill 注入到 nuxt 项目中,根据 browserslist 配置自动检测

Nupolyon

npm versionnpm downloadsLicense

自动注入来自 https://cdnjs.cloudflare.com/polyfill/ 的 polyfill

⚠️ 警告

请勿使用此模块,据报告 POLYFILL.IO 已注入一些恶意代码。我们暂时将 URL 移至 Cloudflare 的镜像。

https://www.bleepingcomputer.com/news/security/polyfillio-javascript-supply-chain-attack-impacts-over-100k-sites/

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

特性

在此处查看详细的功能说明: #58 (评论)

快速设置

  1. nupolyon 依赖添加到您的项目
npx nuxi@latest module add nupolyon
  1. nupolyon 添加到 nuxt.config.tsmodules 部分
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