Skip to content

Instantly share code, notes, and snippets.

@santoshyadavdev
Created January 10, 2023 16:31
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santoshyadavdev/184c615d10d7a321fa1ffcbef7a6692f to your computer and use it in GitHub Desktop.
Save santoshyadavdev/184c615d10d7a321fa1ffcbef7a6692f to your computer and use it in GitHub Desktop.
import {readFileSync} from 'fs';
import {execSync} from 'node:child_process';
import {exec} from 'child_process';
import util from 'util';
export const execAsync = util.promisify(exec);
execSync('npx nx graph --file=workspace-graph.json').toString('utf-8');
const graph = JSON.parse(readFileSync(new URL('../../workspace-graph.json', import.meta.url))).graph;
const graphProjects = Object.entries(graph.nodes);
// get all apps
const apps = graphProjects.filter((project) => project[1].type === 'app');
apps.forEach(async (app) => {
// get dist path
const distPath = app[1].data.targets.build.options.outputPath;
// command to generate the bundle report
const explorerCommand = `npx source-map-explorer ${distPath}/*.js --html reports/${app[0]}/${app[0]}.html`;
// console.log(explorerCommand);
try {
const result = await execAsync(explorerCommand);
} catch (e) {
console.error('result', e);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment