From 4569a48b3b1cb490daf8b4ea8348ed2aeb938976 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 16 Nov 2024 12:25:08 +0100 Subject: [PATCH 1/2] Only compile `app.js` if it has contents --- vite.config.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index 7e70d1dcae5..b06ea97180d 100644 --- a/vite.config.js +++ b/vite.config.js @@ -37,6 +37,13 @@ const hydeVitePlugin = () => ({ } }); +const hasJavaScriptContent = () => { + const appJsPath = resolve(__dirname, 'resources/assets/app.js'); + if (!fs.existsSync(appJsPath)) return false; + const content = fs.readFileSync(appJsPath, 'utf-8'); + return content.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '').trim().length > 0; +}; + export default defineConfig({ server: { port: 5173, @@ -60,7 +67,7 @@ export default defineConfig({ emptyOutDir: false, rollupOptions: { input: [ - resolve(__dirname, 'resources/assets/app.js'), + ...(hasJavaScriptContent() ? [resolve(__dirname, 'resources/assets/app.js')] : []), resolve(__dirname, 'resources/assets/app.css') ], output: { From 64b33c54864d897cdd7ea6a96bd6f733038919ae Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 16 Nov 2024 12:30:21 +0100 Subject: [PATCH 2/2] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 802e893e7f2..92540b521f0 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -123,6 +123,7 @@ This serves two purposes: ### Fixed - Added missing collection key types in Hyde facade method annotations in https://github.com/hydephp/develop/pull/1784 +- The `app.js` file will now only be compiled if it has scripts in https://github.com/hydephp/develop/pull/2028 ### Security