| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ const skipConfig = new Set([ | |||
| 30 | 30 | 'coverage.thresholds.lines', | |
| 31 | 31 | 'standalone', | |
| 32 | 32 | 'clearScreen', | |
| 33 | + 'configLoader', | ||
| 33 | 34 | 'color', | |
| 34 | 35 | 'run', | |
| 35 | 36 | 'hideSkippedTests', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ The ["Running Tests"](/advanced/guide/tests#startvitest) guide has a usage examp | |||
| 61 | 61 | ```ts | |
| 62 | 62 | function createVitest( | |
| 63 | 63 | mode: VitestRunMode, | |
| 64 | - options: UserConfig, | ||
| 64 | + options: CliOptions, | ||
| 65 | 65 | viteOverrides: ViteUserConfig = {}, | |
| 66 | 66 | vitestOptions: VitestOptions = {}, | |
| 67 | 67 | ): Promise<Vitest> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -919,6 +919,12 @@ Removes colors from the console output | |||
| 919 | 919 | ||
| 920 | 920 | Clear terminal screen when re-running tests during watch mode (default: `true`) | |
| 921 | 921 | ||
| 922 | + ### configLoader | ||
| 923 | + | ||
| 924 | + - **CLI:** `--configLoader <loader>` | ||
| 925 | + | ||
| 926 | + Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly. This is only available in vite version 6.1.0 and above. (default: `bundle`) | ||
| 927 | + | ||
| 922 | 928 | ### standalone | |
| 923 | 929 | ||
| 924 | 930 | - **CLI:** `--standalone` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,6 +58,7 @@ export async function createBrowserServer( | |||
| 58 | 58 | }, | |
| 59 | 59 | mode: project.config.mode, | |
| 60 | 60 | configFile: configPath, | |
| 61 | + configLoader: project.vite.config.inlineConfig.configLoader, | ||
| 61 | 62 | // watch is handled by Vitest | |
| 62 | 63 | server: { | |
| 63 | 64 | hmr: false, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - import type { UserConfig as ViteUserConfig } from 'vite' | ||
| 1 | + import type { InlineConfig as ViteInlineConfig, UserConfig as ViteUserConfig } from 'vite' | ||
| 2 | 2 | import type { environments } from '../../integrations/env' | |
| 3 | 3 | import type { Vitest, VitestOptions } from '../core' | |
| 4 | 4 | import type { TestModule, TestSuite } from '../reporters/reported-tasks' | |
@@ -28,6 +28,14 @@ export interface CliOptions extends UserConfig { | |||
| 28 | 28 | * Output collected test files only | |
| 29 | 29 | */ | |
| 30 | 30 | filesOnly?: boolean | |
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * Override vite config's configLoader from cli. | ||
| 34 | + * Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly (default: `bundle`). | ||
| 35 | + * This is only available with **vite version 6.1.0** and above. | ||
| 36 | + * @experimental | ||
| 37 | + */ | ||
| 38 | + configLoader?: ViteInlineConfig extends { configLoader?: infer T } ? T : never | ||
| 31 | 39 | } | |
| 32 | 40 | ||
| 33 | 41 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -806,6 +806,11 @@ export const cliOptionsConfig: VitestCLIOptions = { | |||
| 806 | 806 | description: | |
| 807 | 807 | 'Clear terminal screen when re-running tests during watch mode (default: `true`)', | |
| 808 | 808 | }, | |
| 809 | + configLoader: { | ||
| 810 | + description: | ||
| 811 | + 'Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly. This is only available in vite version 6.1.0 and above. (default: `bundle`)', | ||
| 812 | + argument: '<loader>', | ||
| 813 | + }, | ||
| 809 | 814 | standalone: { | |
| 810 | 815 | description: | |
| 811 | 816 | 'Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,9 @@ import type { | |||
| 2 | 2 | InlineConfig as ViteInlineConfig, | |
| 3 | 3 | UserConfig as ViteUserConfig, | |
| 4 | 4 | } from 'vite' | |
| 5 | + import type { CliOptions } from './cli/cli-api' | ||
| 5 | 6 | import type { VitestOptions } from './core' | |
| 6 | - import type { UserConfig, VitestRunMode } from './types/config' | ||
| 7 | + import type { VitestRunMode } from './types/config' | ||
| 7 | 8 | import { resolve } from 'node:path' | |
| 8 | 9 | import { slash } from '@vitest/utils' | |
| 9 | 10 | import { findUp } from 'find-up' | |
@@ -15,7 +16,7 @@ import { createViteServer } from './vite' | |||
| 15 | 16 | ||
| 16 | 17 | export async function createVitest( | |
| 17 | 18 | mode: VitestRunMode, | |
| 18 | - options: UserConfig, | ||
| 19 | + options: CliOptions, | ||
| 19 | 20 | viteOverrides: ViteUserConfig = {}, | |
| 20 | 21 | vitestOptions: VitestOptions = {}, | |
| 21 | 22 | ): Promise<Vitest> { | |
@@ -33,6 +34,7 @@ export async function createVitest( | |||
| 33 | 34 | ||
| 34 | 35 | const config: ViteInlineConfig = { | |
| 35 | 36 | configFile: configPath, | |
| 37 | + configLoader: options.configLoader, | ||
| 36 | 38 | // this will make "mode": "test" | "benchmark" inside defineConfig | |
| 37 | 39 | mode: options.mode || mode, | |
| 38 | 40 | plugins: await VitestPlugin(options, ctx), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -742,6 +742,7 @@ export async function initializeProject( | |||
| 742 | 742 | const config: ViteInlineConfig = { | |
| 743 | 743 | ...restOptions, | |
| 744 | 744 | configFile, | |
| 745 | + configLoader: ctx.vite.config.inlineConfig.configLoader, | ||
| 745 | 746 | // this will make "mode": "test" | "benchmark" inside defineConfig | |
| 746 | 747 | mode: options.test?.mode || options.mode || ctx.config.mode, | |
| 747 | 748 | plugins: [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + export default 'ok' satisfies string | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments