Skip to content

Commit

Permalink
chore: internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 611616548
  • Loading branch information
asyncLiz authored and copybara-github committed Mar 4, 2024
1 parent 41bfda8 commit 11824b8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 47 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
*.js
!web-test-runner.config.js
!css-to-ts.js
!commitlint.config.js
*.css
*-styles.ts
Expand Down
25 changes: 0 additions & 25 deletions css-to-ts.js

This file was deleted.

34 changes: 13 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
"**/*.js.map",
"**/*.d.ts",
"**/*.scss",
"!css-to-ts.js",
"!web-test-runner.config.js",
"!commitlint.config.js",
"!**/test/**",
"!**/*_test.*",
"!.wireit/**",
"!catalog",
"!catalog/",
"!scripts/",
"!**/testing/**",
"testing/harness.{js,js.map,d.ts}",
Expand Down Expand Up @@ -87,20 +86,18 @@
"**/*.ts",
"!**/*.d.ts",
"!**/*-styles.ts",
"!catalog",
"!scripts/",
"!node_modules"
"!catalog/",
"!scripts/"
],
"output": [
".tsbuildinfo",
"**/*.js",
"**/*.js.map",
"**/*.d.ts",
"!css-to-ts.js",
"!web-test-runner.config.js",
"!commitlint.config.js",
"!types/",
"!catalog",
"!catalog/",
"!scripts/"
],
"clean": "if-file-deleted",
Expand All @@ -109,34 +106,30 @@
]
},
"build:css-to-ts": {
"command": "find . \\( -path ./.wireit -o -path ./node_modules -o -path ./catalog \\) -prune -o -name '*-styles.css' -print | xargs node css-to-ts.js",
"command": "find . \\( -path ./.wireit -o -path ./node_modules -o -path ./catalog \\) -prune -o -name '*-styles.css' -print | xargs -L1 node scripts/css-to-ts.js",
"files": [
"css-to-ts.js",
"!scripts/",
"!node_modules"
"**/*-styles.css",
"!catalog/"
],
"output": [
"**/*-styles.ts",
"!catalog",
"!scripts/"
"!catalog/"
],
"dependencies": [
"build:scripts",
"build:sass"
]
},
"build:sass": {
"command": "sass --style=compressed --load-path=node_modules --load-path=node_modules/sass-true/sass $(ls -d */ | grep -vE 'node_modules|catalog')",
"files": [
"**/*.scss",
"!catalog",
"!scripts/",
"!node_modules"
"!catalog/"
],
"output": [
"**/*.css",
"**/*.css.map",
"!catalog",
"!scripts/"
"!catalog/"
]
},
"test": {
Expand Down Expand Up @@ -177,10 +170,9 @@
"**/*.ts",
"!**/*.d.ts",
"!**/*-styles.ts",
"!catalog",
"!catalog/",
"!scripts/",
"scripts/analyzer/update-docs.js",
"!node_modules"
"scripts/analyzer/update-docs.js"
],
"output": [],
"dependencies": [
Expand Down
31 changes: 31 additions & 0 deletions scripts/css-to-ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as fs from 'fs';

const cssFilePath = process.argv[2];
if (!cssFilePath) {
throw new Error('Usage: node scripts/css-to-ts.js <input.css> [output.ts]');
}

const tsFilePath = process.argv[3] || cssFilePath.replace('.css', '.ts');
const cssContent = fs
.readFileSync(cssFilePath, {encoding: 'utf8'})
// Remove source map comments since the css is embedded.
// "/*# sourceMappingURL=checkbox-styles.css.map */"
.replace(/\/\*#\ sourceMappingURL=[^\*]+ \*\//, '');

const tsContent = `/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/** Generated CSSStyleSheet for ${cssFilePath}. */
export const styles = new CSSStyleSheet();
styles.replaceSync(\`${cssContent}\`);
`;

fs.writeFileSync(tsFilePath, tsContent);

0 comments on commit 11824b8

Please sign in to comment.