vite
vite copied to clipboard
@vitejs/plugin-legacy 自定义 modernPolyfills targets
Description
现在,现代浏览器的polyfills只能基于 { esmodules: true }
,不能自定义,希望新增一个参数来自定义。
Suggested solution
添加一个modernTargets
参数,传给@vitejs/plugin-legacy
,如:
legacy({
targets: ['chrome 87', 'safari 13', 'firefox 78', 'edge 88'],
modernPolyfills: true,
modernTargets: {
browsers: [
// 'defaults',
'chrome 87',
'safari 13',
'firefox 78',
'edge 88'
]
}
})
插件代码如:
await detectPolyfills(raw, { esmodules: !options.modernTargets, ...options.modernTargets }, modernPolyfills);
Alternative
No response
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.