Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: account for absolute paths in token extraction #29848

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tools/extract-tokens/extract-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ function extractTokens(themePath: string): Token[] {

const startMarker = '/*! extract tokens start */';
const endMarker = '/*! extract tokens end */';
const absoluteThemePath = join(process.cwd(), themePath);
const srcPath = join(process.cwd(), 'src');
const root = process.cwd();
const absoluteThemePath = join(root, themePath);
const srcPath = join(root, 'src');
const {prepend, append} = getTokenExtractionCode(
srcPath,
themePath,
Expand All @@ -93,6 +94,16 @@ function extractTokens(themePath: string): Token[] {
compileString(toCompile, {
loadPaths: [srcPath],
url: pathToFileURL(absoluteThemePath),
importers: [
{
findFileUrl: (url: string) => {
const angularPrefix = '@angular/';
return url.startsWith(angularPrefix)
? pathToFileURL(join(srcPath, url.substring(angularPrefix.length)))
: null;
},
},
],
sourceMap: false,
logger: {
debug: message => {
Expand Down
Loading