From 13b87cd82a39ba07d9ce517fc65386ae9843890f Mon Sep 17 00:00:00 2001 From: Kloon ImKloon Date: Sun, 3 Sep 2023 12:16:12 +0200 Subject: [PATCH] Bundle dayjs locales together --- frontend/vite.config.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 109e34b9..19d03c39 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -1,4 +1,3 @@ -import { fileURLToPath, URL } from "node:url"; import path from "node:path"; import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; @@ -53,9 +52,16 @@ export default defineConfig(({ command }) => { build: { rollupOptions: { input: { - index: fileURLToPath( - new URL(`./public/index.html`, import.meta.url) - ), + index: path.resolve(__dirname, "./public/index.html"), + }, + output: { + manualChunks: (id) => { + // bundle dayjs files in a single chunk + // this avoids having small files for each locale + if (id.includes("dayjs/")) { + return "dayjs"; + } + }, }, }, },