npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nuxt3-vite-legacy

v0.1.4

Published

Nuxt3 vite legacy

Downloads

319

Readme

nuxt3-vite-legacy

Nuxt3兼容低版本浏览器的Vite插件

使用说明

  1. 安装:

npm i -D nuxt3-vite-legacy

  1. nuxt.config.ts中引入:
import legacy from "@vitejs/plugin-legacy"
export default defineNuxtConfig({
  modules: ["nuxt3-vite-legacy"],
  vite: {
    plugins: [
      legacy({
        targets: ["Chrome>=51", "iOS>=10"],
        renderLegacyChunks: !0,
        // 常用的polyfills
        // modernPolyfills: ["es.global-this", "es.object.from-entries", "es.array.flat", "es.array.flat-map"],
        // 需安装mdn-polyfills包
        // additionalModernPolyfills: ["mdn-polyfills/Element.prototype.getAttributeNames"],
      })
    ]
  }
})
  1. 配置(非必须):
export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      edge: 88,
      firefox: 78,
      chrome: 87,
      safari: 14
    }
  }
})

@vitejs/plugin-legacy在浏览器端动态插入script,来进行浏览器检测和动态引入资源,在Nuxt3下会导致水合错误。而如果不在浏览器端进行检测,那么兼容性只能做到大概的判断,无法完全精准。

nuxt3-vite-lagacy在服务端通过ua进行浏览器兼容大概判断,默认全部运行兼容逻辑,可以通过runtimeConfig.public.chrome/safari/edge/firefox(如上例,与Vue3对齐)进行个性配置,根据浏览器和平台进行判断,只有<=runtimeConfig.public.chrome/safari/edge/firefox配置值时才运行兼容逻辑。

其它说明

nuxt3-vite-legacy对页面引入的资源做了优化,剔除了legacy构建后引入的冗余资源,关键资源进行预加载,对路径做了一些处理以便支持本地预览和PM2部署。