Skip to content

Commit

Permalink
Simpler config
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jun 1, 2024
1 parent fef5659 commit aaa10d1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export const testableUrls = new Map<string, string[]>();

export function addTests(test: string, urls: string[]): void {
if (import.meta.env.VITE_KEEP_URLS === '1') {
if (import.meta.vitest) {
testableUrls.set(test, urls);
}
}
Expand Down
4 changes: 4 additions & 0 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export default defineConfig({
},
},
},
define: {
// eslint-disable-next-line @typescript-eslint/naming-convention -- no.
'import.meta.vitest': 'true',
},
});
7 changes: 1 addition & 6 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions -- Module augmentation */

/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_KEEP_URLS: string;
}

interface ImportMeta {
readonly vitest: unknown;
readonly env: ImportMetaEnv;
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"build": "run-p build:*",
"build:vite": "vite build",
"build:typescript": "tsc --declaration --emitDeclarationOnly",
"build:demo": "VITE_KEEP_URLS=1 vite build demo",
"build:demo": "vite build demo",
"prepack": "npm run build",
"test": "run-p build test:* xo",
"test:unit": "VITE_KEEP_URLS=1 vitest",
"test:unit": "vitest",
"test:demo": "svelte-check",
"watch": "run-p watch:*",
"watch:typescript": "tsc --watch --noEmit",
Expand Down
5 changes: 3 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import process from 'node:process';
import {defineConfig} from 'vite';

process.env.VITE_KEEP_URLS ??= '0';

export default defineConfig({
build: {
lib: {
Expand All @@ -14,4 +12,7 @@ export default defineConfig({
outDir: 'distribution',
minify: false,
},
define: {
'import.meta.vitest': 'undefined',
},
});

0 comments on commit aaa10d1

Please sign in to comment.