Skip to content

Commit

Permalink
Generate stats charts using rollup-plugin-visualizer
Browse files Browse the repository at this point in the history
Each type of chart available is generated in the 'public' folder so it can be served in the review app
  • Loading branch information
romaricpascal committed Dec 15, 2022
1 parent 653af19 commit d510424
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"postcss-unopacity": "^2.0.0",
"postcss-unrgba": "^1.1.1",
"rollup": "^3.7.4",
"rollup-plugin-visualizer": "^5.8.3",
"sassdoc": "^2.7.4",
"slash": "^5.0.0",
"uglify-js": "^3.17.4",
Expand Down
13 changes: 13 additions & 0 deletions tasks/compile-javascripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { basename, dirname, join, parse } from 'path'

import PluginError from 'plugin-error'
import { rollup } from 'rollup'
import visualizer from 'rollup-plugin-visualizer'
import { minify } from 'uglify-js'

import configPaths from '../config/paths.js'
Expand Down Expand Up @@ -63,6 +64,18 @@ export async function compileJavaScript ([modulePath, { srcPath, destPath, minif
file: filePath,
sourcemapFile: filePath,
sourcemap: true,
plugins:
['sunburst', 'treemap', 'network', 'raw-data', 'list'].map(template => {
const extension = template === 'raw-data'
? 'json'
: template === 'list' ? 'txt' : 'html'

return visualizer.default({
filename: `public/stats-${template}.${extension}`,
title: `"${template}" stats for GOV.UK Frontend`,
template
})
}),

// Universal Module Definition (UMD)
// for browser + Node.js compatibility
Expand Down

0 comments on commit d510424

Please sign in to comment.