Files
react-native-devtools-frontend/scripts/build/generate_css_js_files.js
T
Kriti Sapra 15269c4cf5 Created script to create .css.js files for CSS files
Bug: 1106746
Change-Id: I7612419d19815ce5ad67c842215f65f93ca90769
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2960177
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-06-18 11:18:54 +00:00

40 lines
1.1 KiB
JavaScript

// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const fs = require('fs');
const path = require('path');
const [, , targetName, srcDir, targetGenDir, files] = process.argv;
const filenames = files.split(',');
const configFiles = [];
for (const fileName of filenames) {
const output = fs.readFileSync(path.join(srcDir, fileName), {encoding: 'utf8', flag: 'r'});
fs.writeFileSync(
path.join(targetGenDir, fileName + '.js'),
`// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const styles = new CSSStyleSheet();
styles.replaceSync(
\`${output}
/*# sourceURL=${fileName} */
\`);
export default styles;
`);
configFiles.push(`\"${fileName}\"`);
}
fs.writeFileSync(path.join(targetGenDir, `${targetName}-tsconfig.json`), `{
"compilerOptions": {
"composite": true,
"outDir": "."
},
"files": [
${configFiles.join(',\n ')}
]
}
`);