Skip to content

Commit 2f68d55

Browse files
committed
build: move styling token extraction out of dev workflows
Styling token extraction was included in docs-content because it was the only way to conveniently expose data to the docs site. Now with the proper monorepo setup, this is much easier and we can stop running this JS-based Sass compilation that is rather slow— in development workflows.
1 parent 821c325 commit 2f68d55

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

docs/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ng_app(
4343
"//docs:node_modules/@stackblitz/sdk",
4444
"//docs:node_modules/moment",
4545
"//docs:node_modules/path-normalize",
46+
"//src/material:tokens",
4647
],
4748
)
4849

docs/src/app/pages/component-viewer/component-styling.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Component, inject, Injectable} from '@angular/core';
22
import {DomSanitizer} from '@angular/platform-browser';
33
import {HttpClient} from '@angular/common/http';
44
import {AsyncPipe} from '@angular/common';
5-
import {Observable} from 'rxjs';
5+
import {Observable, of} from 'rxjs';
66
import {map, shareReplay, switchMap} from 'rxjs/operators';
77
import {ComponentViewer} from './component-viewer';
88
import {DocItem} from '../../shared/documentation-items/documentation-items';
@@ -24,7 +24,11 @@ class TokenService {
2424
private _cache: Record<string, Observable<StyleOverridesData>> = {};
2525

2626
getTokenData(item: DocItem): Observable<StyleOverridesData> {
27-
const url = `/docs-content/tokens/${item.packageName}/${item.id}/${item.id}.json`;
27+
if (item.packageName !== 'material') {
28+
console.error('Requested styling token data for package without token data.');
29+
return of({example: null, themes: []});
30+
}
31+
const url = `/assets/tokens/tokens/${item.id}/${item.id}.json`;
2832

2933
if (this._cache[url]) {
3034
return this._cache[url];

docs/src/assets/tokens/BUILD.bazel

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
2+
3+
copy_to_directory(
4+
name = "tokens",
5+
srcs = ["//src/material:tokens"],
6+
replace_prefixes = {
7+
"src/material/": "",
8+
},
9+
visibility = ["//docs:__pkg__"],
10+
)

src/components-examples/BUILD.bazel

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ package_docs_content(
4242
"//src/cdk:overviews": "overviews/cdk",
4343
"//src/material:overviews": "overviews/material",
4444

45-
# Package the extracted token information into the docs content.
46-
"//src/material:tokens": "tokens/material",
47-
4845
# Package the API docs for the Material and CDK package into the docs-content
4946
"//src:api-docs": "api-docs",
5047

0 commit comments

Comments
 (0)