文档管理
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.
 
 
 
 
 
 

81 lines
2.2 KiB

import { fileURLToPath, URL } from 'node:url'
import { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { config } from 'dotenv'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const envFile = mode === 'production' ? '.env.production' : '.env.development'
config({ path: resolve(__dirname, envFile) })
config({ path: resolve(__dirname, '.env') })
return {
plugins: [
vue(),
vueJsx(),
AutoImport({
imports: ['vue'],
resolvers: [
ElementPlusResolver(),
// 自动导入图标组件
IconsResolver({
prefix: 'Icon',
}),
],
}),
Components({
resolvers: [
ElementPlusResolver(),
// 自动注册图标组件
IconsResolver({
enabledCollections: ['ep'],
}),
],
}),
Icons({
autoInstall: true,
}),
],
publicDir: resolve(__dirname, './public'),
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "./src/styles/variables.scss" as *;`,
javascriptEnabled: true,
silenceDeprecations: ["legacy-js-api"],
},
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
public: fileURLToPath(new URL('./public', import.meta.url)),
utils: fileURLToPath(new URL('./src/utils', import.meta.url)),
},
},
optimizeDeps: {
exclude: ['lua.vm.js'],
include: ['@vueuse/core'],
},
server: {
port: 3001,
host: '0.0.0.0',
proxy: {
'/remote': {
target: env.VITE_BASE_URL,
changeOrigin: true,
ws: true,
rewrite: path => path.replace(/^\/remote/, ''),
},
},
},
}
})