import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import tailwindcss from 'tailwindcss';
import AutoImport from 'unplugin-auto-import/vite';
import vueDevTools from 'vite-plugin-vue-devtools';
import Components from 'unplugin-vue-components/vite';
import {ArcoResolver} from 'unplugin-vue-components/resolvers';
import {vitePluginForArco} from "@arco-plugins/vite-vue";
import legacy from '@vitejs/plugin-legacy';
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator';
import allObfuscatorConfig from "./obfuscatorConfig.js";
import {visualizer} from 'rollup-plugin-visualizer';
import viteCompression from 'vite-plugin-compression';

// https://vite.dev/config/
export default defineConfig({
    base: './',
    plugins: [
        vue(),
        vueDevTools(),
        AutoImport({
            resolvers: [ArcoResolver()],
        }),
        Components({
            resolvers: [ArcoResolver({
                sideEffect: true
            })]
        }),
        vitePluginForArco({
            style: 'css'
        }),
        legacy({
            targets: ["defaults", "not IE 11", 'chromeAndroid>=52, iOS>=13.1']
        }),
        vitePluginBundleObfuscator(allObfuscatorConfig),
        viteCompression(),
        visualizer({open: false}),
    ], css: {
        postcss: {
            plugins: [tailwindcss,]
        }
    }, resolve: {
        alias: {
            '@': '/src'
        }
    }, server: {
        host: '0.0.0.0',
        proxy: {
            '/baseApi': {
                target: 'http://192.168.1.105', changeOrigin: true, rewrite: (path) => path.replace(/^\/baseApi/, ''),
            }
        }
    }
})
