2024-11-30
This commit is contained in:
parent
700299157c
commit
23146b62c0
61 changed files with 696 additions and 654 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { fdir } from "fdir";
|
||||
import { resolve } from "node:path";
|
||||
import process from "node:process";
|
||||
import * as v from "valibot";
|
||||
import { defineConfig } from "vite";
|
||||
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";
|
||||
|
|
@ -17,41 +18,47 @@ const SRC_TYPESCRIPT_PATHS = new fdir()
|
|||
/* 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({
|
||||
base: "/",
|
||||
build: {
|
||||
assetsDir: ".",
|
||||
emptyOutDir: true,
|
||||
/* Génère un fichier manifeste dans outDir */
|
||||
manifest: true,
|
||||
minify: true,
|
||||
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: true,
|
||||
entryFileNames: "[name].js",
|
||||
validate: true,
|
||||
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",
|
||||
},
|
||||
treeshake: "smallest",
|
||||
sourcemap: env.VITE_MODE === "production",
|
||||
target: "es2020",
|
||||
write: true,
|
||||
},
|
||||
sourcemap: true,
|
||||
target: "es2020",
|
||||
write: true,
|
||||
},
|
||||
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,
|
||||
}),
|
||||
],
|
||||
mode: env.VITE_MODE ?? "development",
|
||||
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,
|
||||
}),
|
||||
],
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue