Skip to content

Commit

Permalink
feat: set default vite build.outDir to dist/backend
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Nov 7, 2024
1 parent 291797a commit bf450cf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/unplugin-rpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,28 @@ export const unpluginFactory: UnpluginFactory<Options> = (options, meta) => {
name: 'naily:unplugin-rpc',

vite: {
config(config) {
if (!config || !config.build || !config.build.outDir) {
config = config || {}
config.build = config.build || {}
if (!config.build.outDir)
config.build.outDir = 'dist/frontend'
}
},

async configureServer(server) {
const viteDevServer = await useViteDevServer(options || {}, server).run()

if (fs.existsSync(path.join(cwd(), 'naily.config.ts')))
server.watcher.add(path.join(cwd(), 'naily.config.ts'))

server.watcher.add(watchDirs).on('change', async (filePath) => {
const isWatchedFile = createFilter(watchDirs)(filePath)
if (!isWatchedFile || filePath !== path.join(cwd(), 'naily.config.ts'))
return
await viteDevServer.run()
})
},

closeBundle() {
if (options?.buildOnViteCloseBundle === true)
buildServer(options).then(() => exit(0))
Expand Down

0 comments on commit bf450cf

Please sign in to comment.