Handling Browser Compatibility in Vite
2月 7, 2025
·
1 分钟阅读时长
·
79
字
·
-阅读
-评论
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.

