fix: 优化打包/更改浏览器兼容策略
This commit is contained in:
@@ -7,7 +7,8 @@ import * as path from 'path'
|
||||
import imagemin from 'unplugin-imagemin/vite'
|
||||
import viteCompression from 'vite-plugin-compression'
|
||||
import { createHtmlPlugin } from 'vite-plugin-html'
|
||||
import legacy from '@vitejs/plugin-legacy'
|
||||
// import legacy from '@vitejs/plugin-legacy'
|
||||
import { babel } from '@rollup/plugin-babel'
|
||||
import postcssPresetEnv from 'postcss-preset-env'
|
||||
import autoprefixer from 'autoprefixer'
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@@ -19,13 +20,13 @@ export default defineConfig(({ mode }) => {
|
||||
base: '/',
|
||||
plugins: [
|
||||
react(),
|
||||
legacy({
|
||||
targets: ['ie >= 11', 'chrome 52', 'Chrome > 70', 'Safari 12.1', 'ios >= 12.3'],
|
||||
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
||||
renderLegacyChunks: true,
|
||||
polyfills: ['es.promise.all-settled', 'es.object.entries'],
|
||||
modernPolyfills: ['es.promise.all-settled', 'es.object.entries'],
|
||||
}),
|
||||
// legacy({
|
||||
// targets: ['ie >= 11', 'chrome 52', 'Chrome > 70', 'Safari 12.1', 'ios >= 12.3'],
|
||||
// additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
||||
// renderLegacyChunks: true,
|
||||
// polyfills: ['es.promise.all-settled', 'es.object.entries'],
|
||||
// modernPolyfills: ['es.promise.all-settled', 'es.object.entries'],
|
||||
// }),
|
||||
// 修改 icons 相关配置
|
||||
createSvgIconsPlugin({
|
||||
// 指定需要缓存的图标文件夹
|
||||
@@ -131,12 +132,31 @@ export default defineConfig(({ mode }) => {
|
||||
cssCodeSplit: true, // 启用 CSS 代码拆分
|
||||
sourcemap: false, // 构建后是否生成 source map 文件
|
||||
minify: 'esbuild', // 指定使用哪种混淆器
|
||||
polyfillModulePreload: true,
|
||||
write: true, // 启用将构建后的文件写入磁盘
|
||||
emptyOutDir: true, // 构建时清空该目录
|
||||
brotliSize: true, // 启用 brotli 压缩大小报告
|
||||
chunkSizeWarningLimit: 2000, // chunk 大小警告的限制
|
||||
watch: null, // 设置为 {} 则会启用 rollup 的监听器
|
||||
rollupOptions: {
|
||||
plugins: [
|
||||
// https://www.npmjs.com/package/@rollup/plugin-babel
|
||||
babel({
|
||||
babelHelpers: 'bundled',
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
useBuiltIns: 'entry', // 注意这里只能使用 entry
|
||||
corejs: '3',
|
||||
targets: 'last 2 versions and not dead, > 0.2%, Firefox ESR',
|
||||
},
|
||||
],
|
||||
],
|
||||
plugins: [],
|
||||
compact: false,
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
|
Reference in New Issue
Block a user