1 changed files with 66 additions and 65 deletions
-
131vite.config.ts
@ -1,73 +1,74 @@ |
|||
import { defineConfig, loadEnv } from 'vite' |
|||
import {defineConfig, loadEnv} from 'vite' |
|||
import vue from '@vitejs/plugin-vue' |
|||
import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import' |
|||
import {lazyImport, VxeResolver} from 'vite-plugin-lazy-import' |
|||
import legacy from '@vitejs/plugin-legacy' |
|||
import path from 'path' |
|||
import { visualizer } from 'rollup-plugin-visualizer' |
|||
import {visualizer} from 'rollup-plugin-visualizer' |
|||
|
|||
// https://vite.dev/config/
|
|||
export default defineConfig(({ mode }) => { |
|||
const env = loadEnv(mode, process.cwd()) |
|||
console.log('当前环境:', mode) |
|||
console.log('当前环境变量:', env) |
|||
return { |
|||
esbuild: { |
|||
supported: { |
|||
bigint: true |
|||
}, |
|||
treeShaking: true |
|||
}, |
|||
plugins: [ |
|||
vue(), |
|||
visualizer({ |
|||
open: true, // 打包完成后自动展示
|
|||
gzipSize: true, // 显示gzip压缩后的大小
|
|||
brotliSize: true // 显示brotli压缩后的大小
|
|||
}), |
|||
legacy({ |
|||
targets: ['defaults', 'not IE 11', 'chrome >=73'], |
|||
modernPolyfills: true |
|||
}), |
|||
lazyImport({ |
|||
resolvers: [ |
|||
VxeResolver({ |
|||
libraryName: 'vxe-table' |
|||
}), |
|||
VxeResolver({ |
|||
libraryName: 'vxe-pc-ui' |
|||
}) |
|||
] |
|||
}) |
|||
], |
|||
server: { |
|||
host: true // 允许外部设备访问
|
|||
}, |
|||
resolve: { |
|||
alias: { |
|||
'@': path.resolve(__dirname, './src') |
|||
} |
|||
}, |
|||
base: process.env.NODE_ENV === 'production' ? './' : '/', |
|||
build: { |
|||
sourcemap: false, // 关闭 sourcemap
|
|||
minify: 'terser', |
|||
terserOptions: { |
|||
compress: { |
|||
drop_console: true, // 生产环境去除console
|
|||
drop_debugger: true // 生产环境去除 debugger
|
|||
export default defineConfig(({mode}) => { |
|||
const env = loadEnv(mode, process.cwd()) |
|||
console.log('当前环境:', mode) |
|||
console.log('当前环境变量:', env) |
|||
return { |
|||
esbuild: { |
|||
supported: { |
|||
bigint: true |
|||
}, |
|||
treeShaking: true, |
|||
drop: ['console', 'debugger'], |
|||
}, |
|||
plugins: [ |
|||
vue(), |
|||
visualizer({ |
|||
open: true, // 打包完成后自动展示
|
|||
gzipSize: true, // 显示gzip压缩后的大小
|
|||
brotliSize: true // 显示brotli压缩后的大小
|
|||
}), |
|||
legacy({ |
|||
targets: ['defaults', 'not IE 11', 'chrome >=73'], |
|||
modernPolyfills: true |
|||
}), |
|||
lazyImport({ |
|||
resolvers: [ |
|||
VxeResolver({ |
|||
libraryName: 'vxe-table' |
|||
}), |
|||
VxeResolver({ |
|||
libraryName: 'vxe-pc-ui' |
|||
}) |
|||
] |
|||
}) |
|||
], |
|||
server: { |
|||
host: true // 允许外部设备访问
|
|||
}, |
|||
resolve: { |
|||
alias: { |
|||
'@': path.resolve(__dirname, './src') |
|||
} |
|||
}, |
|||
base: process.env.NODE_ENV === 'production' ? './' : '/', |
|||
build: { |
|||
sourcemap: false, // 关闭 sourcemap
|
|||
minify: 'terser', |
|||
terserOptions: { |
|||
compress: { |
|||
drop_console: true, // 生产环境去除console
|
|||
drop_debugger: true // 生产环境去除 debugger
|
|||
} |
|||
}, |
|||
rollupOptions: { |
|||
output: { |
|||
manualChunks: { |
|||
echarts: ['echarts'], |
|||
xlsx: ['xlsx'], |
|||
lodash: ['lodash'], |
|||
vue: ['vue', 'vue-router', 'pinia'], |
|||
elementPlus: ['element-plus'] |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
rollupOptions: { |
|||
output: { |
|||
manualChunks: { |
|||
echarts: ['echarts'], |
|||
xlsx: ['xlsx'], |
|||
lodash: ['lodash'], |
|||
vue: ['vue', 'vue-router', 'pinia'], |
|||
elementPlus: ['element-plus'] |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue