mirror of
https://github.com/material-components/material-web.git
synced 2024-10-05 17:48:16 +03:00
chore: update css-to-ts script
PiperOrigin-RevId: 612919272
This commit is contained in:
parent
41bfda8dca
commit
1c2197bd30
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,7 +1,6 @@
|
||||
node_modules
|
||||
*.js
|
||||
!web-test-runner.config.js
|
||||
!css-to-ts.js
|
||||
!commitlint.config.js
|
||||
*.css
|
||||
*-styles.ts
|
||||
|
25
css-to-ts.js
25
css-to-ts.js
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
|
||||
for (let i = 2; i < process.argv.length; i++) {
|
||||
try {
|
||||
const filePath = process.argv[i];
|
||||
const content = fs.readFileSync(filePath);
|
||||
fs.writeFileSync(filePath.replace('.css', '.ts'), `/**
|
||||
* @license
|
||||
* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import {css} from 'lit';
|
||||
export const styles = css\`${content.toString('utf8')}\`;
|
||||
`);
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
34
package.json
34
package.json
@ -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}",
|
||||
@ -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",
|
||||
@ -109,18 +106,17 @@
|
||||
]
|
||||
},
|
||||
"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"
|
||||
]
|
||||
},
|
||||
@ -128,15 +124,12 @@
|
||||
"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": {
|
||||
@ -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": [
|
||||
|
32
scripts/css-to-ts.ts
Normal file
32
scripts/css-to-ts.ts
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @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=[^\*]+ \*\//, '');
|
||||
|
||||
fs.writeFileSync(
|
||||
tsFilePath,
|
||||
`/**
|
||||
* @license
|
||||
* Copyright 2024 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
// Generated stylesheet for ${cssFilePath}.
|
||||
import {css} from 'lit';
|
||||
export const styles = css\`${cssContent}\`;
|
||||
`,
|
||||
);
|
Loading…
Reference in New Issue
Block a user