import { fileURLToPath, resolve, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `
          @import "@/assets/scss/variables/_border-radius.scss";
          @import "@/assets/scss/variables/_box-shadow.scss";
          @import "@/assets/scss/variables/_breakpoints.scss";
          @import "@/assets/scss/variables/_colors.scss";
          @import "@/assets/scss/variables/_font-sizes.scss";
          @import "@/assets/scss/variables/_font-weight.scss";
          @import "@/assets/scss/variables/_global.scss";
          @import "@/assets/scss/variables/_height.scss";
          @import "@/assets/scss/variables/_index.scss";
          @import "@/assets/scss/variables/_spacing.scss";
          @import "@/assets/scss/variables/_transition.scss";
          @import "@/assets/scss/variables/_width.scss";
        `,
      },
    },
  },
  build: {
    lib: {
      // tell the build process to treat this project as library
      entry: "src/index.ts",
      name: "gr-components-dev-test",
      fileName: (format) => `${format}.js`,
    },
    rollupOptions: {
      // make sure to externalize deps that shouldn't be bundled
      // into your library
      external: ["vue", "vue-router"],
      output: {
        // Provide global variables to use in the UMD build
        // for externalized deps
        globals: {
          vue: "Vue",
        },
      },
    },
  },
});
