- une mise à jour WooCommerce a changé les clés attendues des adresses dans le corps de la requête pour la création d'une comande.
71 lines
2.4 KiB
JavaScript
Executable file
71 lines
2.4 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 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()),
|
|
});
|
|
|
|
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: "smallest",
|
|
},
|
|
sourcemap: env.VITE_MODE === "production",
|
|
target: "es2020",
|
|
write: true,
|
|
},
|
|
mode: env.VITE_MODE ?? "production",
|
|
plugins: [
|
|
// 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,
|
|
}),
|
|
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: false,
|
|
}),
|
|
],
|
|
};
|
|
});
|