# nuxt3-vite-legacy

Nuxt3 module compatible with legacy browsers.

#### Quick Setup
1. Install:

`npm i -D nuxt3-vite-legacy`

2. In `nuxt.config.ts`:

```
import legacy from "@vitejs/plugin-legacy"
export default defineNuxtConfig({
  modules: [["nuxt3-vite-legacy", {edge: 79, firefox: 78, chrome: 87, safari: 12}]], // Parameters are not required
  vite: {
    plugins: [
      legacy({
        targets: ["Chrome>=51", "iOS>=10"],
        renderLegacyChunks: true,
        // Commonly used polyfills
        // modernPolyfills: ["es.global-this", "es.object.from-entries", "es.array.flat", "es.array.flat-map"],
        // Need to install mdn-polyfills
        // additionalModernPolyfills: ["mdn-polyfills/Element.prototype.getAttributeNames"],
      })
    ]
  }
})
```
`nuxt3-vite-lagacy` performs a general browser compatibility check on the server through UA. By default, all compatibility logic is run, and personalized configuration can be made through `modules: [["nuxt3-vite-legacy", {edge: 79, firefox: 78, chrome: 87, safari: 12}]]`. The judgment is based on the browser and platform, and compatibility logic is only run when the configuration value is<=chrome/safari/edge/firefox.
#### Other
`nuxt3-vite-legacy` has optimized the resources introduced into the page, removing redundant resources introduced after legacy, preloading key resources, and processing paths to support local preview and PM2 deployment.
