diff --git a/packages/cli/bin/oxfmt b/packages/cli/bin/oxfmt index efae3059a5..442fc01fa2 100755 --- a/packages/cli/bin/oxfmt +++ b/packages/cli/bin/oxfmt @@ -12,8 +12,12 @@ if (!process.argv.includes('--lsp')) { import { createRequire } from 'node:module'; import { pathToFileURL } from 'node:url'; +import pkg from '../package.json' with { type: 'json' }; const require = createRequire(import.meta.url); const oxfmtBin = require.resolve('oxfmt/bin/oxfmt'); +// This allows oxfmt to load vite.config.ts +// For `vp check` and `vp fmt`, see `src/utils/constants.ts` +process.env.VITE_PLUS_VERSION = pkg.version; await import(pathToFileURL(oxfmtBin).href); diff --git a/packages/cli/bin/oxlint b/packages/cli/bin/oxlint index 2385020e74..64301c4850 100755 --- a/packages/cli/bin/oxlint +++ b/packages/cli/bin/oxlint @@ -13,9 +13,13 @@ if (!process.argv.includes('--lsp')) { import { createRequire } from 'node:module'; import { dirname, join } from 'node:path'; import { pathToFileURL } from 'node:url'; +import pkg from '../package.json' with { type: 'json' }; const require = createRequire(import.meta.url); const oxlintMainPath = require.resolve('oxlint'); const oxlintBin = join(dirname(dirname(oxlintMainPath)), 'bin', 'oxlint'); +// This allows oxlint to load vite.config.ts +// For `vp check` and `vp lint`, see `src/utils/constants.ts` +process.env.VITE_PLUS_VERSION = pkg.version; await import(pathToFileURL(oxlintBin).href); diff --git a/packages/cli/src/utils/constants.ts b/packages/cli/src/utils/constants.ts index 4adf161730..ab154f619a 100644 --- a/packages/cli/src/utils/constants.ts +++ b/packages/cli/src/utils/constants.ts @@ -29,4 +29,7 @@ export const DEFAULT_ENVS = { JS_RUNTIME_NAME: process.release.name, // Indicate that vite-plus is the package manager NODE_PACKAGE_MANAGER: 'vite-plus', + // This allows oxlint/oxfmt to load vite.config.ts + // For `--lsp` path, see `bin/oxlint` and `bin/oxfmt` + VITE_PLUS_VERSION, } as const;