- étoffe le fichier `JOURNAL` avec les nouveaux changements majeurs. - propose une tâche _Justfile_ pour un rechargement à chaud primitif lors de changements CSS. - ne précompresse pas et ne propose plus de versions « legacy » des scripts JS en methodes développement. - appose correctement `aria-current` sur le lien de la page courante dans les deux menus de navigation. - remplace une image statique « Scroll down » avec une animation SVG reposant sur du texte et des chemins. - renomme moultes choses.
85 lines
2.7 KiB
JavaScript
Executable file
85 lines
2.7 KiB
JavaScript
Executable file
import legacy from "@vitejs/plugin-legacy";
|
|
import { fdir } from "fdir";
|
|
import { resolve } from "node:path";
|
|
import process from "node:process";
|
|
import * as v from "valibot";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import { compression } from "vite-plugin-compression2";
|
|
import manifestSRI from "vite-plugin-manifest-sri";
|
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
import valibot from "vite-plugin-valibot-env";
|
|
|
|
const SLUG_THEME = "haiku-atelier-2024";
|
|
const SRC_TYPESCRIPT_PATHS = new fdir()
|
|
.withBasePath()
|
|
.filter((path, isDirectory) => !isDirectory && !path.endsWith("d.ts"))
|
|
.withMaxDepth(0)
|
|
.crawl(`web/app/themes/${SLUG_THEME}/src/scripts`)
|
|
.withPromise();
|
|
|
|
// 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),
|
|
manifestSRI({ algorithms: ["sha512"] }),
|
|
nodePolyfills({
|
|
include: [],
|
|
protocolImports: true,
|
|
}),
|
|
];
|
|
// Les extensions activées en production.
|
|
const prodPlugins = [
|
|
legacy({
|
|
modernPolyfills: true,
|
|
modernTargets:
|
|
"chrome >0 and last 3 years, edge >0 and last 3 years, safari >0 and last 3 years, firefox >0 and last 3 years, and_chr >0 and last 3 years, and_ff >0 and last 3 years, ios >0 and last 3 years",
|
|
renderLegacyChunks: true,
|
|
}),
|
|
compression({
|
|
algorithms: [
|
|
"brotliCompress",
|
|
"gzip",
|
|
"zstandard",
|
|
],
|
|
threshold: 1000,
|
|
}),
|
|
];
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "VITE");
|
|
|
|
return {
|
|
base: "/",
|
|
build: {
|
|
assetsDir: ".",
|
|
emptyOutDir: true,
|
|
// Génère un fichier manifeste dans outDir.
|
|
manifest: true,
|
|
minify: env["VITE_MODE"] === "production",
|
|
outDir: resolve("./web/app/themes/haiku-atelier-2024/assets/js"),
|
|
reportCompressedSize: true,
|
|
rollupOptions: {
|
|
input: await SRC_TYPESCRIPT_PATHS,
|
|
output: {
|
|
assetFileNames: "[name].[hash].[extname]",
|
|
chunkFileNames: "[name].[hash].js",
|
|
compact: env["VITE_MODE"] === "production",
|
|
entryFileNames: "[name].js",
|
|
validate: true,
|
|
},
|
|
treeshake: true,
|
|
},
|
|
sourcemap: env["VITE_MODE"] === "production",
|
|
target: "es2020",
|
|
write: true,
|
|
},
|
|
mode: env["VITE_MODE"] ?? "production",
|
|
plugins: env["VITE_MODE"] === "production" ? [...basePlugins, ...prodPlugins] : [...basePlugins],
|
|
};
|
|
});
|