Handling Browser Compatibility in Vite
·
1 min read
·
79
Words
·
-Views
-Comments
Vite ships an official solution for legacy browser support.
Install the Plugin
npm install @vitejs/plugin-legacy
Configure
plugins: [
// ... other plugins
legacy({
targets: [
'defaults',
'chrome >= 55',
'safari >= 12',
'not IE 11',
'firefox >= 52',
],
}),
]
The plugin simplifies compatibility—no need to fiddle with Browserslist or core-js directly.
Notes
- Because polyfills are injected based on targets, expect longer build times.
- Avoid configuring core-js manually; the plugin handles it.
Final Thoughts
That’s all—quick and clean.