vite打包后报错globalThis is not defined
问题:浏览器版本65globalThis需要chrome 71以上vite+vue3.0打包项目后,浏览器提示globalThis is not defined。解答:修改vite.config.js添加插件@vitejs/plugin-legacyimport legacy from '@vitejs/plugin-legacy'export default defineConfig({plug
·
问题:
浏览器版本65
globalThis需要chrome 71以上
vite+vue3.0打包项目后,浏览器提示globalThis is not defined。
解答:
修改vite.config.js
添加插件@vitejs/plugin-legacy
import legacy from '@vitejs/plugin-legacy'
export default defineConfig({
plugins: [
legacy({
targets: ['Chrome 63'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
modernPolyfills: true
})
],
build:{
target:'es2015'
}
})
重新打包即可
更多推荐
已为社区贡献1条内容
所有评论(0)