12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { fileURLToPath, URL } from 'node:url';
- import { defineConfig, loadEnv } from 'vite';
- import vue from '@vitejs/plugin-vue';
- import vueJsx from '@vitejs/plugin-vue-jsx';
- import vueDevTools from 'vite-plugin-vue-devtools';
- import legacy from '@vitejs/plugin-legacy';
- import AutoImport from 'unplugin-auto-import/vite';
- import Components from 'unplugin-vue-components/vite';
- import { VantResolver } from '@vant/auto-import-resolver';
- import tailwindcss from '@tailwindcss/vite';
- // https://vite.dev/config/
- export default defineConfig(({ mode, command }) => {
- const dir = './.env';
- const env = loadEnv(mode, dir, '');
- const prefix = env.APP_ENV_PREFIX || 'VITE_';
- return {
- envDir: dir,
- envPrefix: prefix,
- define: {
- __app_base__: JSON.stringify(env.APP_BASE),
- __app_name__: JSON.stringify(process.env.npm_package_name),
- __app_version__: JSON.stringify(process.env.npm_package_version),
- },
- base: env.APP_BASE,
- plugins: [
- vue(),
- vueJsx(),
- vueDevTools(),
- tailwindcss(),
- AutoImport({
- imports: ['vue', 'vue-router', 'pinia'],
- resolvers: [VantResolver()],
- dts: '@types/auto-imports.d.ts',
- }),
- Components({
- resolvers: [VantResolver()],
- dts: '@types/components.d.ts',
- }),
- ],
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url)),
- '@request': fileURLToPath(new URL('./request', import.meta.url)),
- '@model': fileURLToPath(new URL('./model', import.meta.url)),
- '@tool': fileURLToPath(new URL('./tool', import.meta.url)),
- },
- },
- server: {
- host: '0.0.0.0',
- port: 51001,
- proxy: {
- '/manager': {
- target: env.APP_API_PROXY,
- secure: false,
- changeOrigin: false,
- logLevel: 'debug',
- },
- },
- },
- };
- });
|