Skip to content

Commit c5ddd03

Browse files
brenelzryansolid
andauthored
Fix Vite 6 environment detection (#173)
* Fix vite6 environment detection * Create lucky-hats-arrive.md --------- Co-authored-by: Ryan Carniato <[email protected]>
1 parent 2c071db commit c5ddd03

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/lucky-hats-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vite-plugin-solid": patch
3+
---
4+
5+
Fix vite6 environment detection

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
181181
let needHmr = false;
182182
let replaceDev = false;
183183
let projectRoot = process.cwd();
184+
let isTestMode = false;
184185

185186
return {
186187
name: 'solid',
@@ -190,6 +191,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
190191
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
191192
replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
192193
projectRoot = userConfig.root;
194+
isTestMode = userConfig.mode === 'test';
193195

194196
if (!userConfig.resolve) userConfig.resolve = {};
195197
userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
@@ -270,7 +272,12 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
270272
config.resolve.conditions = [...defaultServerConditions];
271273
}
272274
}
273-
config.resolve.conditions.push('solid');
275+
config.resolve.conditions = [
276+
'solid',
277+
...(replaceDev ? ['development'] : []),
278+
...(isTestMode && !opts.isSsrTargetWebworker ? ['browser'] : []),
279+
...config.resolve.conditions,
280+
];
274281
},
275282

276283
configResolved(config) {

0 commit comments

Comments
 (0)