Skip to content

Commit

Permalink
refactor!: remove hotfile option
Browse files Browse the repository at this point in the history
  • Loading branch information
benny123tw committed Jul 7, 2024
1 parent bffcc84 commit 54a29ef
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 25 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ dist-ssr
*.sln
*.sw?

# Plugin hot file
hot

# Java
target/
build/
1 change: 1 addition & 0 deletions examples/vanilla/client/public/hot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://localhost:5173
4 changes: 0 additions & 4 deletions packages/vite-plugin-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default defineConfig({
target: 'es2015'
}
},
hotFile: 'public/hot',
transformOnServe: (code, url) => code.replace('__PLACEHOLDER__', url)
})
]
Expand All @@ -56,7 +55,6 @@ export default defineConfig({
| `outputDirectory` | `string` | `'dist'` | Directory where the bundle should be written |
| `tsCompiler` | `'esbuild'` \| `'swc'` | `'esbuild'` | @experimental TypeScript compiler to use |
| `swcOptions` | `SwcOptions` | `{}` | @experimental Options to pass to the SWC compiler |
| `hotFile` | `string` | `'public/hot'` | Path to the "hot" file |
| `transformOnServe` | `(code: string, url: DevServerUrl) => string` | `code => code` | Transform the code while serving |

### Example
Expand Down Expand Up @@ -84,7 +82,6 @@ export default {
target: 'es2015'
}
},
hotFile: 'static/hot',
transformOnServe: (code, url) => code.replace('__VITE_URL__', url)
})
]
Expand All @@ -109,7 +106,6 @@ export interface VitePluginJavaConfig {
outputDirectory?: string
tsCompiler?: SupportedTSCompiler
swcOptions?: SwcOptions
hotFile?: string
transformOnServe?: (code: string, url: DevServerUrl) => string
}

Expand Down
7 changes: 0 additions & 7 deletions packages/vite-plugin-java/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ export interface VitePluginJavaConfig {
*/
outputDirectory?: string

/**
* The path to the "hot" file.
*
* @default `${publicDirectory}/hot`
*/
hotFile?: string

/**
* The path to the Java project root.
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/vite-plugin-java/src/vite-plugin-java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ function resolveJavaPlugin(pluginConfig: Required<VitePluginJavaConfig>): [JavaP
if (isAddressInfo(address)) {
viteDevServerUrl = userConfig.server?.origin ? userConfig.server.origin as DevServerUrl : resolveDevServerUrl(address, server.config)

fs.writeFileSync(pluginConfig.hotFile, `${viteDevServerUrl}${server.config.base.replace(/\/$/, '')}`)

setTimeout(() => {
server.config.logger.info(`\n ${colors.red(`${colors.bold('JAVA')} ${javaVersion(pluginConfig.javaProjectBase)}`)} ${colors.dim('plugin')} ${colors.bold(`v${pluginVersion()}`)}`)
server.config.logger.info('')
Expand All @@ -140,14 +138,6 @@ function resolveJavaPlugin(pluginConfig: Required<VitePluginJavaConfig>): [JavaP
})

if (!exitHandlersBound) {
const clean = () => {
debug?.('cleaning up hot file.')
if (fs.existsSync(pluginConfig.hotFile)) {
fs.rmSync(pluginConfig.hotFile)
}
}

process.on('exit', clean)
process.on('SIGINT', () => process.exit())
process.on('SIGTERM', () => process.exit())
process.on('SIGHUP', () => process.exit())
Expand Down Expand Up @@ -212,7 +202,6 @@ function resolvePluginConfig(config: string | string[] | VitePluginJavaConfig):
buildDirectory: config.buildDirectory ?? 'build',
publicDirectory: config.publicDirectory ?? 'public',
outputDirectory: config.outputDirectory ?? 'dist',
hotFile: config.hotFile ?? path.join((config.publicDirectory ?? 'public'), 'hot'),
javaProjectBase: config.javaProjectBase ?? '.',
transformOnServe: config.transformOnServe ?? (code => code),
}
Expand Down

0 comments on commit 54a29ef

Please sign in to comment.