Skip to content

Commit

Permalink
[kbn/ui-shared-deps] track asset sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Sep 29, 2020
1 parent da134f3 commit bc94795
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/kbn-ui-shared-deps/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
*/

const Path = require('path');
const Fs = require('fs');

const { run, createFailError } = require('@kbn/dev-utils');
const { run, createFailError, CiStatsReporter } = require('@kbn/dev-utils');
const webpack = require('webpack');
const Stats = require('webpack/lib/Stats');
const del = require('del');

const { distDir } = require('../index');
const { getWebpackConfig } = require('../webpack.config');

run(
Expand All @@ -42,6 +44,37 @@ run(
const took = Math.round((stats.endTime - stats.startTime) / 1000);

if (!stats.hasErrors() && !stats.hasWarnings()) {
if (!flags.dev) {
const reporter = CiStatsReporter.fromEnv(log);

const metrics = [
{
group: '@kbn/ui-shared-deps asset size',
id: 'kbn-ui-shared-deps.js',
value: Fs.statSync(Path.resolve(distDir, 'kbn-ui-shared-deps.js')).size,
},
{
group: '@kbn/ui-shared-deps asset size',
id: '[email protected]',
value: Fs.statSync(Path.resolve(distDir, '[email protected]')).size,
},
{
group: '@kbn/ui-shared-deps asset size',
id: 'css',
value:
Fs.statSync(Path.resolve(distDir, 'kbn-ui-shared-deps.css')).size +
Fs.statSync(Path.resolve(distDir, 'kbn-ui-shared-deps.v7.light.css')).size,
},
];

log.debug('metrics:', metrics);

reporter.metrics(metrics).catch((error) => {
log.error('Failed to report stats with CiStatsReporter');
log.error(error);
});
}

log.success(`webpack completed in about ${took} seconds`);
return;
}
Expand Down

0 comments on commit bc94795

Please sign in to comment.