Skip to content

Commit b418b52

Browse files
authored
Merge pull request #2028 from hydephp/only-compile-app-scripts-if-it-has-content
[2.x] Only compile app scripts if it has contents
2 parents c42d8fe + 64b33c5 commit b418b52

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ This serves two purposes:
123123
### Fixed
124124

125125
- Added missing collection key types in Hyde facade method annotations in https://github.com/hydephp/develop/pull/1784
126+
- The `app.js` file will now only be compiled if it has scripts in https://github.com/hydephp/develop/pull/2028
126127

127128
### Security
128129

vite.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ const hydeVitePlugin = () => ({
3737
}
3838
});
3939

40+
const hasJavaScriptContent = () => {
41+
const appJsPath = resolve(__dirname, 'resources/assets/app.js');
42+
if (!fs.existsSync(appJsPath)) return false;
43+
const content = fs.readFileSync(appJsPath, 'utf-8');
44+
return content.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g, '').trim().length > 0;
45+
};
46+
4047
export default defineConfig({
4148
server: {
4249
port: 5173,
@@ -60,7 +67,7 @@ export default defineConfig({
6067
emptyOutDir: false,
6168
rollupOptions: {
6269
input: [
63-
resolve(__dirname, 'resources/assets/app.js'),
70+
...(hasJavaScriptContent() ? [resolve(__dirname, 'resources/assets/app.js')] : []),
6471
resolve(__dirname, 'resources/assets/app.css')
6572
],
6673
output: {

0 commit comments

Comments
 (0)