mirror of
https://github.com/material-components/material-web.git
synced 2024-09-11 21:57:41 +03:00
33 lines
812 B
TypeScript
33 lines
812 B
TypeScript
/**
|
|
* @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}\`;
|
|
`,
|
|
);
|