Files
react-native-devtools-frontend/scripts/build/ninja/minify-json-files.js
T
Simon Zünd 957496f839 Minify locale JSON files at build time
This CL adds a new build rule "minify_json" that takes a list of JSON
files, minifies them, and puts the result into then "gen/" directory.

The i18n module uses the new rule to minify the locale JSON, reducing
the raw size per locale file 10-15%.

R=tvanderlippe@chromium.org

Fixed: 1293324
Change-Id: I0aabc5cdea7957334dfe21304e117dc23a563606
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3431345
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
2022-02-02 13:19:01 +00:00

20 lines
682 B
JavaScript

// Copyright 2022 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 {writeIfChanged} = require('./write-if-changed.js');
const [, , src, dest, files] = process.argv;
for (const file of files.split(',')) {
const srcPath = path.join(src, file);
const destPath = path.join(dest, file);
// Minifying JSON is straight-forward as JSON.stringify omits whitespace.
const srcContents = fs.readFileSync(srcPath);
const destContents = JSON.stringify(JSON.parse(srcContents));
writeIfChanged(destPath, destContents);
}