Skip to content

Commit

Permalink
fix: ensure proper resolve condition set for vitest env
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Oct 1, 2023
1 parent c7f0c6b commit 7a4b118
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-plums-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/vite": patch
---

Fix support for using this plugin with Vitest and a browser environment.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ export default function markoPlugin(opts: Options = {}): vite.Plugin[] {

if (isTest) {
linked = false;

if (
((config as any).test?.environment as string | undefined)?.includes(
"dom"
)
) {
config.resolve ??= {};
config.resolve.conditions ??= [];
config.resolve.conditions.push("browser");
}
}

if (linked && !registeredTag) {
Expand Down

0 comments on commit 7a4b118

Please sign in to comment.