Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 7, 2023
1 parent c0337c1 commit 6fb8783
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,19 @@ export function assets(options?: { entryDirectories?: string[] }): Plugin {
server.middlewares.use((req, _res, next) => {
// this is necessary so that /tests will load tests/index
// otherwise this would only happen when /tests/ or /tests/index.html is opened
// but then the tests will fail because the ember app will try to route to tests/ which does not exist
if (req.originalUrl?.match(/\/tests($|\?)/) || req.originalUrl?.startsWith('/tests/index.html')) {
environment = 'test';
req.originalUrl = '/tests/index.html';
(req as any).url = '/tests/index.html';
if (InMemoryAssets['index.html']) {
// need to invalidate modules when switching between app and tests
server.moduleGraph.invalidateAll();
InMemoryAssets = {};
}
return next();
}
if (req.originalUrl === '/' || req.originalUrl === '/index.html') {
// need to invalidate modules when switching between app and tests
if (InMemoryAssets['tests/index.html']) {
server.moduleGraph.invalidateAll();
InMemoryAssets = {};
Expand Down

0 comments on commit 6fb8783

Please sign in to comment.