Skip to content

Commit

Permalink
fix(vite): use replace only once per function call
Browse files Browse the repository at this point in the history
use replace only once per function in nx-tsconfig-paths-find-file
  • Loading branch information
KonstantinKai authored and Coly010 committed Dec 12, 2024
1 parent 2492d7e commit 607bf62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/utils/nx-tsconfig-paths-find-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export function findFile(
extensions: string[],
existsSyncImpl: typeof existsSync = existsSync
): string {
const queryLessPath = path.replace(/\?\S*$/, '');

for (const ext of extensions) {
const dir = dirname(path);
// Support file extensions such as .css and .js in the import path.
const [dir, name] = [
dirname(path),
basename(path.replace(/\?\S*$/, ''), ext),
];
const name = basename(queryLessPath, ext);

const resolvedPath = resolve(dir, name + ext);
if (existsSyncImpl(resolvedPath)) {
Expand Down

0 comments on commit 607bf62

Please sign in to comment.