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 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: {