HELP
This commit is contained in:
parent
c6664a7597
commit
e05e9553f5
1250 changed files with 23379 additions and 147730 deletions
|
|
@ -1,12 +1,9 @@
|
|||
import legacy from "@vitejs/plugin-legacy";
|
||||
import { fdir, PathsOutput } from "fdir";
|
||||
import { resolve } from "node:path";
|
||||
import path 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 { VitePhpManifest } from "vite-php-manifest";
|
||||
import valibot from "vite-plugin-valibot-env";
|
||||
|
||||
const SLUG_THEME = "haiku-atelier-2024";
|
||||
|
|
@ -16,6 +13,7 @@ const SRC_TYPESCRIPT_PATHS: Promise<PathsOutput> = new fdir()
|
|||
.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({
|
||||
|
|
@ -27,31 +25,13 @@ const SCHEMA_ENVIRONNEMENT = v.object({
|
|||
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,
|
||||
VitePhpManifest({
|
||||
shortArraySyntax: true,
|
||||
unlinkOriginManifest: false,
|
||||
}),
|
||||
];
|
||||
|
||||
export default defineConfig(async ({ mode }) => {
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "VITE");
|
||||
console.debug(env);
|
||||
|
||||
|
|
@ -59,22 +39,18 @@ export default defineConfig(async ({ mode }) => {
|
|||
base: "/",
|
||||
build: {
|
||||
assetsDir: ".",
|
||||
cssMinify: "lightningcss",
|
||||
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"),
|
||||
outDir: "./web/app/themes/haiku-atelier-2024/assets/js",
|
||||
reportCompressedSize: true,
|
||||
rollupOptions: {
|
||||
input: await SRC_TYPESCRIPT_PATHS,
|
||||
experimental: {
|
||||
incrementalBuild: true,
|
||||
nativeMagicString: true,
|
||||
},
|
||||
input: PATHS,
|
||||
output: {
|
||||
assetFileNames: "[name].[hash].[extname]",
|
||||
chunkFileNames: "[name].[hash].js",
|
||||
entryFileNames: "[name].js",
|
||||
assetFileNames: "[hash].[extname]",
|
||||
chunkFileNames: "[hash].js",
|
||||
entryFileNames: "[name].[hash].js",
|
||||
minify: env["VITE_MODE"] === "production",
|
||||
},
|
||||
treeshake: true,
|
||||
|
|
@ -83,7 +59,11 @@ export default defineConfig(async ({ mode }) => {
|
|||
target: "es2020",
|
||||
write: true,
|
||||
},
|
||||
css: {
|
||||
devSourcemap: true,
|
||||
transformer: "lightningcss",
|
||||
},
|
||||
mode: env["VITE_MODE"] ?? "production",
|
||||
plugins: env["VITE_MODE"] === "production" ? [...basePlugins, ...prodPlugins] : [...basePlugins],
|
||||
plugins: [...basePlugins],
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue