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 28, 2024
1 parent f331ec1 commit b7a5253
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 @@ -19,6 +19,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 @@ -164,7 +166,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 b7a5253

Please sign in to comment.