import { UserConfig } from 'vite';

interface ProxyConf {
    target: string;
    matches: string[];
    negate?: boolean;
}

interface TopViteConfig {
    port: number;
    siteName: string;
    siteDescription: string;
    /** The absolute url online that `staticPath` files can be retrieved from
     * E.g. https://example.com/static
     */
    staticUrl: string;
    /** The os path to the files that will deployed to `staticUrl`.
     * E.g. /.../static
     */
    staticPath: string;
    /** The absolute url online that `sameDomStaticPath` files can be retrieved from
     * Note if the static files are hosted on the same domain (i.e. not linking to a cdn, these can be the same as main static version)
     * E.g. https://example.com/~sds
     */
    sameDomStaticUrl: string;
    /** The os path to the files that will deployed to `sameDomStaticUrl`.
     * Note if the static files are hosted on the same domain (i.e. not linking to a cdn, these can be the same as main static version)
     * E.g. /.../~sds
     */
    sameDomStaticPath: string;
    favicon192PngPath: string;
    favicon512PngPath: string;
    /** Proxy rules to apply to the dev server (i.e. when it should forward requests to a backend) */
    proxy?: ProxyConf;
    /** Extra globs to exclude from traversal, can help with performance: */
    extraNonFrontendGlobs?: string[];
    /** Include the inspect plugin, which allows you to see how vite is transforming code: */
    inspect?: boolean;
    serverFs?: Exclude<UserConfig["server"], undefined>["fs"];
    /** Allows vite to handle custom import phrases, note if they're in tsconfig not 100% sure if this is needed.
    *   E.g. import { resolve } from "path";
        alias: {
            "@": resolve("./bitbazaar"),
        }

        Or better yet, just use the tsconfig paths:
        import tsconfig from "./tsconfig.json";
        alias: tsconfig.compilerOptions.paths,
     */
    alias?: Exclude<UserConfig["resolve"], undefined>["alias"];
}
/** An opinionated outer config wrapper for vite (layers upon layers!!). To prevent having unique & complex config setups across multiple similar projects.
 * This handles index minification, css, scss, preact, pwa, service worker etc and the fact they can't come from a separate CDN.
 * Designed to work with a custom index.html file.
 *
 * CSS:
 * - css/scss is handled automatically, postcss.config.cjs is being detected automatically
 * - foo.module.s?css identifies local, everything else is treated as global
 * - (for potential future compatibility still globals as write as foo.global.s?css)
 *
 * HTML ENTRY:
 * - Vite looks for an index.html file at the root, there's currently no way to configure this.
 * - If you need to preprocess in any way, e.g. django or etch. You'll have to have a source you preprocess first before running vite, writing it to root/index.html.
 * - Vite will process it further
 * - The final minified index.html will be added to the assets folder, where it should be the root of a static site, or server manually from a backend server.
 */
declare const createConfig: (mode: string, conf: TopViteConfig) => UserConfig;

export { type TopViteConfig, createConfig };
