import { defineConfig } from "vite"
import vuePlugin from "@vitejs/plugin-vue"
import windicssPlugin from "vite-plugin-windicss"
import pagesPlugin from "vite-plugin-pages"
import iconsPlugin from "unplugin-icons/vite"
import gzipPlugin from "rollup-plugin-gzip"
import { promisify } from "node:util"
import { brotliCompress as brotliCompressCallback } from "node:zlib"

const brotliCompress = promisify(brotliCompressCallback)

export default defineConfig({
  plugins: [
    vuePlugin(),
    pagesPlugin(),
    windicssPlugin(),
    iconsPlugin(),
    gzipPlugin({
      minSize: 1501
    }),
    gzipPlugin({
      minSize: 1501,
      fileName: ".br",
      customCompression: content => brotliCompress(Buffer.from(content))
    })
  ],
  // @ts-expect-error
  ssgOptions: {
    formatting: "minify",
    dirStyle: "nested"
  }
})
