Skip to content

Commit

Permalink
chore: respect ssr flag in clientInjectsions transform
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 20, 2024
1 parent a5efd56 commit 8c5674e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
.replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement)
}
},
async transform(code, id) {
async transform(code, id, options) {
if (!this.environment) return
// TODO: !environment.options.nodeCompatible ?
const ssr = this.environment.name !== 'client'
// TODO: Remove options?.ssr, Vitest currently hijacks this plugin
const ssr = options?.ssr ?? this.environment.name !== 'client'
if (id === normalizedClientEntry || id === normalizedEnvEntry) {
return injectConfigValues(code)
} else if (!ssr && code.includes('process.env.NODE_ENV')) {
Expand Down

0 comments on commit 8c5674e

Please sign in to comment.