Skip to content

Commit

Permalink
Added clean-css to minify CSS on release build
Browse files Browse the repository at this point in the history
Bug: 1106746
Change-Id: I4165bb4fa30564dc3b8eff942f6cb341a6e31ffb
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3037550
Commit-Queue: Kriti Sapra <[email protected]>
Reviewed-by: Tim van der Lippe <[email protected]>
Reviewed-by: Jack Franklin <[email protected]>
  • Loading branch information
Kriti Sapra authored and Devtools-frontend LUCI CQ committed Jul 20, 2021
1 parent 01167d8 commit bc43679
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/build/generate_css_js_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
// found in the LICENSE file.
const fs = require('fs');
const path = require('path');
const [, , targetName, srcDir, targetGenDir, files] = process.argv;
const CleanCSS = require('clean-css');
const [, , isDebugString, targetName, srcDir, targetGenDir, files] = process.argv;

const filenames = files.split(',');
const configFiles = [];
const cleanCSS = new CleanCSS();
const isDebug = isDebugString === 'true';

for (const fileName of filenames) {
const output = fs.readFileSync(path.join(srcDir, fileName), {encoding: 'utf8', flag: 'r'});
Expand All @@ -18,7 +21,7 @@ for (const fileName of filenames) {
// found in the LICENSE file.
const styles = new CSSStyleSheet();
styles.replaceSync(
\`${output}
\`${isDebug ? output : cleanCSS.minify(output).styles}
/*# sourceURL=${fileName} */
\`);
export default styles;
Expand Down
4 changes: 4 additions & 0 deletions scripts/build/ninja/generate_css.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ template("generate_css") {
_src = rebase_path(".", root_build_dir)
_dest = rebase_path(target_gen_dir, root_build_dir)

inputs +=
[ devtools_location_prepend + "node_modules/clean-css/package.json" ]

args = [
"$is_debug",
target_name,
_src,
_dest,
Expand Down

0 comments on commit bc43679

Please sign in to comment.