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

fix(config): watch envDir even outside of root #12349

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ export type ResolvedConfig = Readonly<
/** @internal */
mainConfig: ResolvedConfig | null
isProduction: boolean
/** @internal */
envDir: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe enough to not need to make this internal. Currently, ResolvedConfig has envDir?: string | undefined, this would make a previous public API internal, which is sort-of a breaking change.

Removing the /** @internal */ comment should be good.

Suggested change
/** @internal */
envDir: string
envDir: string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. nice catch. I feel even more that we need some type checking (maybe leverage tsd). I'll give it a try.

env: Record<string, any>
resolve: Required<ResolveOptions> & {
alias: Alias[]
Expand Down Expand Up @@ -659,6 +661,7 @@ export async function resolveConfig(
server,
build: resolvedBuildOptions,
preview: resolvePreviewOptions(config.preview, server),
envDir,
env: {
...userEnv,
BASE_URL,
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ export async function createServer(
}

const watcher = chokidar.watch(
// config file dependencies might be outside of root
[path.resolve(root), ...config.configFileDependencies],
// config file dependencies and env file might be outside of root
[root, ...config.configFileDependencies, config.envDir],
resolvedWatchOptions,
) as FSWatcher

Expand Down