Closed guguji5 closed 2 years ago
polyfillModulePreload
is a polyfill for modulepreload
. https://vitejs.dev/config/#build-polyfillmodulepreload
String::replaceAll
is not supported at Chrome 84.
Vite does not include polyfills automatically.
If you want to include polyfill, use plugin-legacy
or include it manually.
@sapphi-red I config the plugin-legacy as below, but it still doesn't work, I just want to add the replaceAll polyfill
export default defineConfig({
plugins: [
legacy({ targets: ['Chrome 63'], modernPolyfills: true, polyfills: ['es.string.replace', 'esnext.string.replace-all'] }),
],
build: {
target: 'chrome63',
}
}
@guguji5 You need to change modernPolyfills
.
export default defineConfig({
plugins: [
legacy({ targets: ['Chrome 63'], modernPolyfills: ['es.string.replace', 'esnext.string.replace-all'], polyfills: ['es.string.replace', 'esnext.string.replace-all'] }),
],
build: {
target: 'chrome63',
}
}
@sapphi-red it works as expect, thank you
Describe the bug
I set
build: {polyfillModulePreload: true,target: 'chrome58'}
in vite.config.ts, butTypeError: a.replaceAll is not a function
throw at chrome84.Reproduction
https://github.com/n9e/fe-v5
System Info
Used Package Manager
npm
Logs
Validations