import vue from "@vitejs/plugin-vue";
import {visualizer} from "rollup-plugin-visualizer";
import strip from "@rollup/plugin-strip";
import viteCompression from "vite-plugin-compression";
import vueJsx from '@vitejs/plugin-vue-jsx'

const path = require("path");

export default {
    base: './',
    plugins: [
        vue(),
        vueJsx(),
        //正式环境打包去除调试语句
        {
            ...strip({
                include: ["**/*.js", "**/*.vue", "**/*.ts", "**/*.jsx"],
            }),
            apply: "build",
        },
        //打包开启gzip压缩
        viteCompression(),
    ],
    resolve: {
        alias: {
            // 键必须以斜线开始和结束
            "@": path.resolve(__dirname, "./src"),
        },
    },
    css: {
        preprocessorOptions: {
            scss: {
                //添加scss全局变量样式
                additionalData: "@import './src/styles/global.scss';",
            },
        },
    },
    server: {
        // 配置调试服务器主机名，如果允许外部访问，可设置为"0.0.0.0"
        host: "0.0.0.0",
        port: 3000, // 服务器端口号
        open: false, // 是否自动打开浏览器
        proxy: {
            '/api': {
                // 王坤画像测试地址
                // target: 'https://windata.platomix.net/dev/api',
                // target: 'http://demo.platomix.net/api',
                // target: 'https://windata.platomix.net/huaxiang/api',
                // 王坤画像预生产地址
                // target: 'https://data.platomix.net/huaxiang/api',
                // 北城
                // target: 'https://windata.platomix.net/api',
                // target: 'https://saber.platomix.net/api',
                target: 'http://demo.platomix.net',
                // 正式地址
                // target: 'https://data.mige.tv/api',
                changeOrigin: true,
                rewrite: (path) => path.replace(new RegExp(`^/api`), ''),
            }
        }
    },
};
