Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show warning to discourage putting process/global to define option #14447

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,21 @@ export async function resolveConfig(
customLogger: config.customLogger,
})

let foundDiscouragedVariableName
if (
(foundDiscouragedVariableName = Object.keys(config.define ?? {}).find((k) =>
['process', 'global'].includes(k),
))
) {
logger.warn(
colors.yellow(
`Putting ${colors.bold(
foundDiscouragedVariableName,
)} to define option is discoraged. See https://vitejs.dev/config/shared-options.html#define for more details.`,
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
),
)
}

// resolve root
const resolvedRoot = normalizePath(
config.root ? path.resolve(config.root) : process.cwd(),
Expand Down