Skip to content

Commit 0b1b819

Browse files
committed
fix(@angular/build): support injecting global styles into vitest unit-tests
1 parent 3d65518 commit 0b1b819

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

  • packages/angular/build/src/builders/unit-test

packages/angular/build/src/builders/unit-test/builder.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,25 @@ export async function* execute(
257257
];
258258
},
259259
},
260+
{
261+
name: 'angular-html-index',
262+
transformIndexHtml() {
263+
// Add all global stylesheets
264+
return (
265+
Object.entries(result.files)
266+
// TODO: Expand this to all configured global stylesheets
267+
.filter(([file]) => file === 'styles.css')
268+
.map(([styleUrl]) => ({
269+
tag: 'link',
270+
attrs: {
271+
'href': styleUrl,
272+
'rel': 'stylesheet',
273+
},
274+
injectTo: 'head',
275+
}))
276+
);
277+
},
278+
},
260279
],
261280
},
262281
);

0 commit comments

Comments
 (0)