- ajoute les fichiers de langage et les scripts JS aux exclusions Git - met à jour les dépendances et retire celles pour Vite inutilisées - formate les YAML et TOML avec la commande du justfile - nettoie la configuration Vite
63 lines
1.9 KiB
TypeScript
Executable file
63 lines
1.9 KiB
TypeScript
Executable file
import { fdir, PathsOutput } from "fdir";
|
|
import process from "node:process";
|
|
import * as v from "valibot";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import valibot from "vite-plugin-valibot-env";
|
|
|
|
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;
|
|
|
|
// Voir le fichier vite.env.d.ts.
|
|
const SCHEMA_ENVIRONNEMENT = v.object({
|
|
VITE_GLITCHTIP_NSD: v.pipe(v.string(), v.url(), v.readonly()),
|
|
VITE_MODE: v.pipe(v.string(), v.readonly()),
|
|
VITE_URL: v.pipe(v.string(), v.nonEmpty(), v.url(), v.readonly()),
|
|
});
|
|
|
|
const basePlugins = [
|
|
// Permet de valider les variables d'environnements définies à partir d'un schéma Valibot
|
|
valibot(SCHEMA_ENVIRONNEMENT),
|
|
];
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "VITE");
|
|
console.debug(env);
|
|
|
|
return {
|
|
base: "/",
|
|
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",
|
|
plugins: [...basePlugins],
|
|
};
|
|
});
|