Skip to content

Commit

Permalink
feat: show warning to discourage putting process/global to define o…
Browse files Browse the repository at this point in the history
…ption (#14447)
  • Loading branch information
sapphi-red authored Sep 26, 2023
1 parent 27e5b11 commit 83a56f7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,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(
`Replacing ${colors.bold(
foundDiscouragedVariableName,
)} using the define option is discouraged. See https://vitejs.dev/config/shared-options.html#define for more details.`,
),
)
}

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

0 comments on commit 83a56f7

Please sign in to comment.