From 70efa458a3fb92131c7e400d17029abf3b2bf603 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Tue, 29 Nov 2022 15:36:42 +0100 Subject: [PATCH] Better code splitting --- index.html | 10 ++-------- vite.config.js | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 7b53266..617ed98 100644 --- a/index.html +++ b/index.html @@ -13,14 +13,8 @@ href="https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400;1,600&family=Lato:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap" rel="stylesheet" /> - - + + diff --git a/vite.config.js b/vite.config.js index 80c7f64..555a5cc 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,4 +1,4 @@ -import { defineConfig } from 'vite' +import { defineConfig, splitVendorChunkPlugin } from 'vite' import dotenv from 'dotenv' import preact from '@preact/preset-vite' @@ -9,5 +9,19 @@ console.log(`[Config] BASE_URL = "${process.env.BASE_URL}"`) export default defineConfig({ base: process.env.BASE_URL, - plugins: [preact()], + build: { + rollupOptions: { + output: { + manualChunks(id) { + if (id.includes('katex')) { + return 'katex' + } + if (id.includes('unified') || id.includes('remark') || id.includes('rehype')) { + return 'markdown' + } + }, + }, + }, + }, + plugins: [splitVendorChunkPlugin(), preact()], })