49 lines
1.4 KiB
TypeScript
Executable file
49 lines
1.4 KiB
TypeScript
Executable file
import type { PathsOutput } from "fdir";
|
|
import { fdir } from "fdir";
|
|
import process from "node:process";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
|
|
const SLUG_THEME = "haiku-atelier-2024";
|
|
const SRC_TYPESCRIPT_PATHS: Promise<PathsOutput> = new fdir()
|
|
.withBasePath()
|
|
.filter((path, isDirectory) => !isDirectory && !path.endsWith("d.ts"))
|
|
.withMaxDepth(0)
|
|
.crawl(`web/app/themes/${SLUG_THEME}/src/scripts`)
|
|
.withPromise();
|
|
const PATHS = await SRC_TYPESCRIPT_PATHS;
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "VITE");
|
|
|
|
return {
|
|
base: "/",
|
|
cacheDir: ".cache/vite",
|
|
build: {
|
|
assetsDir: ".",
|
|
cssMinify: "lightningcss",
|
|
emptyOutDir: true,
|
|
manifest: true,
|
|
minify: env["VITE_MODE"] === "production",
|
|
outDir: "./web/app/themes/haiku-atelier-2024/assets/js",
|
|
reportCompressedSize: true,
|
|
rollupOptions: {
|
|
input: PATHS,
|
|
output: {
|
|
assetFileNames: "[hash].[extname]",
|
|
chunkFileNames: "[hash].js",
|
|
entryFileNames: "[name].js",
|
|
minify: env["VITE_MODE"] === "production",
|
|
},
|
|
treeshake: true,
|
|
},
|
|
sourcemap: env["VITE_MODE"] === "development",
|
|
target: "es2020",
|
|
write: true,
|
|
},
|
|
css: {
|
|
devSourcemap: true,
|
|
transformer: "lightningcss",
|
|
},
|
|
mode: env["VITE_MODE"] ?? "production",
|
|
};
|
|
});
|