Skip to content

Conversation

@benny123tw
Copy link
Member

Summary

This PR restores the hotfile feature that was removed in commit 588863c, addressing issue #2. The hotfile is now configurable and can be disabled by setting hotFile to false.

Why is this needed?

The hotfile allows Spring applications to detect when the Vite dev server is running. Spring can check for the existence of this file to determine whether to:

  • Load assets from the Vite dev server (development mode)
  • Load assets from the build directory (production mode)

Changes

  • ✅ Add hotFile configuration option to VitePluginJavaConfig (string | false)
  • ✅ Write hotfile on server start containing the dev server URL
  • ✅ Clean up hotfile automatically on process exit
  • ✅ Update .gitignore to ignore the hot file
  • ✅ Update README with hotfile documentation and examples

Configuration

The hotfile is enabled by default at public/hot, but can be customized or disabled:

```typescript
java({
input: 'src/main.ts',
hotFile: 'static/hot', // Custom path
// or
hotFile: false, // Disable hotfile generation
})
```

Test Plan

  • Lint passes
  • Type checks pass
  • All tests pass
  • Feature tested manually

Closes #2

🤖 Generated with Claude Code

Add back the hotfile feature that was removed in commit 588863c.
The hotfile is now configurable and can be disabled by setting
hotFile to false.

The hotfile allows Spring applications to detect when the Vite
dev server is running by checking for the existence of the file,
which contains the dev server URL.

Changes:
- Add hotFile option to VitePluginJavaConfig (string | false)
- Write hotfile on server start with dev server URL
- Clean up hotfile on process exit
- Update .gitignore to ignore hot file
- Update README with hotfile documentation

Closes #2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@benny123tw benny123tw requested a review from Copilot October 12, 2025 13:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restores the hotfile feature for the Vite Java plugin, allowing Spring applications to detect when the Vite dev server is running by checking for a hotfile containing the server URL.

  • Adds configurable hotFile option that can be set to a custom path or disabled with false
  • Automatically writes hotfile on server start and cleans it up on process exit
  • Updates documentation with hotfile configuration examples

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/vite-plugin-java/src/vite-plugin-java.ts Implements hotfile writing on server start and cleanup on exit
packages/vite-plugin-java/src/index.ts Adds hotFile configuration option to the interface
packages/vite-plugin-java/README.md Documents the new hotFile configuration option with examples

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 152 to 154
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())
process.on('SIGHUP', () => process.exit())
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup function should also be called for the other process exit handlers to ensure the hotfile is cleaned up in all exit scenarios.

Suggested change
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())
process.on('SIGHUP', () => process.exit())
process.on('SIGINT', () => { clean(); process.exit() })
process.on('SIGTERM', () => { clean(); process.exit() })
process.on('SIGHUP', () => { clean(); process.exit() })

Copilot uses AI. Check for mistakes.
Comment on lines 152 to 154
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())
process.on('SIGHUP', () => process.exit())
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These signal handlers should call the cleanup function before exiting to ensure the hotfile is removed when the process is terminated by signals.

Suggested change
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())
process.on('SIGHUP', () => process.exit())
process.on('SIGINT', () => { clean(); process.exit() })
process.on('SIGTERM', () => { clean(); process.exit() })
process.on('SIGHUP', () => { clean(); process.exit() })

Copilot uses AI. Check for mistakes.
@benny123tw benny123tw merged commit c2e7f49 into main Oct 12, 2025
4 checks passed
@benny123tw benny123tw deleted the feat/restore-hotfile-option branch October 12, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: Readd hotfile feature

2 participants