Skip to content

Commit fddb813

Browse files
committed
Step 2 - Intercept and replace Vite
1 parent 6f6291d commit fddb813

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

libs/nx-angular-mf/src/builders/custom-loader/custom-loader-serve.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
import { Context, DefaultLoad, NextResolve } from './types';
2-
2+
import { join } from 'path';
33

44
export async function initialize({ port }: { port: MessagePort }) {
55
port.onmessage = async (event) => {};
66
}
77

88
export async function resolve(
9-
specifierInput: string,
9+
specifier: string,
1010
context: Context,
1111
nextResolve: NextResolve
1212
) {
13-
nextResolve(specifierInput, context, nextResolve);
13+
const { parentURL } = context;
14+
if (
15+
specifier.startsWith('vite') &&
16+
parentURL.indexOf('@angular/build') > -1
17+
) {
18+
return nextResolve(
19+
join(__dirname, 'patch-vite-dev-server.js'),
20+
context,
21+
nextResolve
22+
);
23+
}
24+
25+
return nextResolve(specifier, context, nextResolve);
1426
}
1527

1628
export async function load(

0 commit comments

Comments
 (0)