2022-11-21 22:54:35 +08:00

69 lines
1.6 KiB
TypeScript

import { ConfigEnv, UserConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import eslintPlugin from 'vite-plugin-eslint';
import { resolve } from 'path';
import { loadEnv } from 'vite';
import Unocss from 'unocss/vite';
import PurgeIcons from 'vite-plugin-purge-icons';
// https://vitejs.cn/config/
export default ({ mode }: ConfigEnv): UserConfig => {
const root = process.cwd();
const env = loadEnv(mode, root);
return {
base: './',
resolve: {
alias: {
'@': resolve('./src'),
},
},
define: {
'process.env': {},
},
server: {
host: true,
// open: true,
port: env.VITE_PORT as any,
proxy: {
'/api': {
target: env.VITE_BASE_URL,
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
},
'/upload': {
target: env.VITE_BASE_URL,
changeOrigin: true,
rewrite: path => path.replace(/^\/upload/, ''),
},
},
},
plugins: [
uni(),
Unocss(),
PurgeIcons({
content: [
'**/*.html',
'**/*.js',
'**/*.ts',
'**/*.vue',
'**/*.jsx',
'**/*.tsx',
'**/*.json',
],
}),
// eslintPlugin({
// include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.ts'],
// exclude: ['./node_modules/**'],
// cache: false,
// }),
],
css: {
preprocessorOptions: {
scss: {
// additionalData: '@import "@/assets/style/main.scss";',
},
},
},
};
};