12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { defineConfig, loadEnv, type ConfigEnv, type UserConfig } from 'vite'
- import { initVitePlugins } from './plugins'
- import { initProxy } from './plugins/proxy'
- import { resolve } from 'path'
- import { wrapperEnv } from './getEnv'
- const pathSrc = resolve(__dirname, 'src')
- // https://vite.dev/config/
- export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
- const root = process.cwd()
- const env = loadEnv(mode, root)
- const viteEnv = wrapperEnv(env)
- return {
- server: {
- port: viteEnv.VITE_PORT,
- open: viteEnv.VITE_OPEN,
- proxy: initProxy(viteEnv.VITE_PROXY)
- },
- resolve: {
- alias: {
- '@': pathSrc
- }
- },
- plugins: initVitePlugins(viteEnv, command === 'build'),
- build: {
- outDir: 'dist',
- minify: 'esbuild',
- sourcemap: false
- },
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: `@use "@/assets/styles/element/index.scss" as *;`
- }
- }
- },
- optimizeDeps: {
- include: ['vue', 'vue-router', 'pinia', 'vue-i18n', 'axios', '@vueuse/core']
- }
- }
- })
|