Skip to content

Commit

Permalink
fix(config): delete cache correctly when restarting server (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
CHOYSEN committed Jan 15, 2021
1 parent 9f54510 commit bd3b1bf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/config.ts
Expand Up @@ -433,7 +433,7 @@ export async function loadConfigFromFile(
// 1. try to directly require the module (assuming commonjs)
try {
// clear cache in case of server restart
delete require.cache[resolvedPath]
delete require.cache[require.resolve(resolvedPath)]
userConfig = require(resolvedPath)
debug(`cjs config loaded in ${Date.now() - start}ms`)
} catch (e) {
Expand Down Expand Up @@ -530,7 +530,8 @@ async function loadConfigFromBundledFile(
defaultLoader(module, filename)
}
}
delete require.cache[fileName]
// clear cache in case of server restart
delete require.cache[require.resolve(fileName)]
const raw = require(fileName)
const config = raw.__esModule ? raw.default : raw
require.extensions[extension] = defaultLoader
Expand Down

0 comments on commit bd3b1bf

Please sign in to comment.