Skip to content

Commit

Permalink
fix: skip checking outDir upon preview
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Nov 16, 2022
1 parent 1191021 commit 7629b18
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions telefunc/node/vite/plugins/previewConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export { previewConfig }

import type { Plugin, ResolvedConfig } from 'vite'
import { assertUsage, getOutDirs, determineOutDir } from '../utils'
import { determineOutDir } from '../utils'
import { apply, addTelefuncMiddleware } from '../helpers'
import fs from 'fs'

function previewConfig(): Plugin {
let config: ResolvedConfig
Expand All @@ -19,19 +18,9 @@ function previewConfig(): Plugin {
enforce: 'post',
configurePreviewServer(server) {
return () => {
assertDist()
;(process.env as Record<string, string>).NODE_ENV = 'production'
addTelefuncMiddleware(server.middlewares)
}
}
}
function assertDist() {
let { outDirRoot, outDirClient, outDirServer } = getOutDirs(config)
;[outDirRoot, outDirClient, outDirServer].forEach((outDirAny) => {
assertUsage(
fs.existsSync(outDirAny),
`Cannot run \`$ vite preview\`: your app isn't built (the build directory ${outDirAny} is missing). Make sure to run \`$ vite build\` before running \`$ vite preview\`.`
)
})
}
}

0 comments on commit 7629b18

Please sign in to comment.