You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

56 lines
1.6 KiB

import path from 'path'
import { defineConfig } from 'vite'
import type { Plugin, PluginOption } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import legacy from '@vitejs/plugin-legacy'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import WindiCSS from 'vite-plugin-windicss'
export default defineConfig(({ mode, command }) => {
const isBuild = command === 'build' // 是否是打包环境的判断
const plugins: (Plugin | Plugin[] | PluginOption[])[] = [
vue(),
WindiCSS(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
directoryAsNamespace: true,
}),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/svgicons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
]
isBuild && plugins.push(legacy()) // 是打包环境,就把legacy()加入到plugins中
return {
plugins,
server: {
      host: '0.0.0.0'
    },
    publicPath: './',
    base: './',
    build: {
      outDir: 'hukou',
      assetsDir: 'assets',
    },
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
}
})