import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";
import path from "path";
import Components from "unplugin-vue-components/vite";
import viteCompression from "vite-plugin-compression";

export default defineConfig(({ mode }) => {
  return {
    esbuild: {
      drop: mode === "production" ? ["console", "debugger"] : [],
    },
    plugins: [
      viteCompression(),
      vue({
        template: {
          transformAssetUrls: {
            base: null,
            includeAbsolute: false,
          },
        },
      }),
      laravel({
        input: [
          "resources/sass/app-front.scss",
          "resources/js/app-front.js",
          "resources/sass/app-auth.scss",
          "resources/js/app-auth.js",
        ],
        refresh: true,
      }),
      Components({
        dirs: ["resources/js/vue"],
        dts: false,
      }),
    ],
    resolve: {
      alias: {
        vue: "vue/dist/vue.esm-bundler.js",
        "@": path.resolve(__dirname, "./resources/js"),
        "~": path.resolve(__dirname, "node_modules"),
        "~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
      },
    },
  };
});
