From 2567f5fb62ba5d850fffcb2bc3b3e27a1552333a Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Tue, 27 May 2025 23:37:31 -0600 Subject: [PATCH] Add a build step in dev mode to create a symlink to the compendium packs on disk --- vite.config.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index f2b5aca..ed76b76 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,9 +1,9 @@ /* eslint-disable no-undef */ +import { readFileSync, symlinkSync } from "fs"; import { defineConfig } from "vite"; import { glob } from "glob"; import path from "path"; -import { readFileSync } from "fs"; // MARK: custom plugins function fileMarkerPlugin() { @@ -41,6 +41,24 @@ function watcher(...globs) { }; }; +/* +The intent of this plugin is to handle the symlinking of the compendium packs +so that they can modified during dev without needing to worry about the rebuild +destroying the in-progress compendia data. +*/ +function handlePacks() { + return { + writeBundle(options) { + console.log(options.dir); + symlinkSync( + path.resolve(__dirname, `packs`), + `${options.dir}/packs`, + `dir`, + ); + }, + }; +}; + // MARK: config export default defineConfig(({ mode }) => { const isProd = mode === `prod`; @@ -49,6 +67,7 @@ export default defineConfig(({ mode }) => { if (!isProd) { plugins.push( + handlePacks(), watcher( `./public`, ),