Created
January 10, 2023 16:31
-
-
Save santoshyadavdev/184c615d10d7a321fa1ffcbef7a6692f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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