Skip to content

Commit

Permalink
chore: improve deps check
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 23, 2024
1 parent 2664587 commit a68737d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { resolveTester } from './serverTester'
export { defineBrowserCommand } from './commands/utils'
export type { BrowserCommand } from 'vitest/node'

const versionRegexp = /(?:\?|&)v=\w{8}/

export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
const project = browserServer.project

Expand Down Expand Up @@ -161,7 +163,7 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
// them in _some_ tests, while keeping original modules in others
// there is no way to configure that in Vite, so we patch it here
// to always ignore the cache-control set by Vite in the next middleware
if (req.url && req.url.includes('/deps/') && !req.url.includes('chunk-')) {
if (req.url && versionRegexp.test(req.url) && !req.url.includes('chunk-')) {
res.setHeader('Cache-Control', 'no-cache')
const setHeader = res.setHeader.bind(res)
res.setHeader = function (name, value) {
Expand Down

0 comments on commit a68737d

Please sign in to comment.