Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@
"ts_library-test": "./third_party/typescript/tests/verify_ts_libary.sh",
"unittest": "scripts/test/run_unittests.py --no-text-coverage",
"watch": "third_party/node/node.py --output scripts/watch_build.js"
},
"devDependencies": {
"sync-fetch": "latest"
}
}
8 changes: 7 additions & 1 deletion scripts/build/generate_css_js_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.
const fs = require('fs');
const path = require('path');
const fetch = require('sync-fetch');
const CleanCSS = require('clean-css');
const [, , isDebugString, targetName, srcDir, targetGenDir, files] = process.argv;

Expand All @@ -11,16 +12,21 @@ const configFiles = [];
const cleanCSS = new CleanCSS();
const isDebug = isDebugString === 'true';

const constructibleStyleSheetsPolyfill = fetch('https://unpkg.com/construct-style-sheets-polyfill@3.0.0/dist/adoptedStyleSheets.js').text();

for (const fileName of filenames) {
let output = fs.readFileSync(path.join(srcDir, fileName), {encoding: 'utf8', flag: 'r'});
output = output.replace(/\`/g, '\\\'');
output = output.replace(/\\/g, '\\\\');

fs.writeFileSync(
path.join(targetGenDir, fileName + '.js'),
`// Copyright ${new Date().getFullYear()} The Chromium Authors. All rights reserved.
`${constructibleStyleSheetsPolyfill}

// 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(
\`${isDebug ? output : cleanCSS.minify(output).styles}
Expand Down