feat: restore configurable hotfile option#3
Conversation
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>
There was a problem hiding this comment.
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
hotFileoption that can be set to a custom path or disabled withfalse - 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.
| process.on('SIGINT', () => process.exit()) | ||
| process.on('SIGTERM', () => process.exit()) | ||
| process.on('SIGHUP', () => process.exit()) |
There was a problem hiding this comment.
The cleanup function should also be called for the other process exit handlers to ensure the hotfile is cleaned up in all exit scenarios.
| 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() }) |
| process.on('SIGINT', () => process.exit()) | ||
| process.on('SIGTERM', () => process.exit()) | ||
| process.on('SIGHUP', () => process.exit()) |
There was a problem hiding this comment.
These signal handlers should call the cleanup function before exiting to ensure the hotfile is removed when the process is terminated by signals.
| 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() }) |
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
hotFiletofalse.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:
Changes
hotFileconfiguration option toVitePluginJavaConfig(string | false).gitignoreto ignore thehotfileConfiguration
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
Closes #2
🤖 Generated with Claude Code