Skip to content

Commit

Permalink
chore: fix the rollup bundle visualiser output (#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Jul 23, 2024
1 parent de0f3b6 commit 9b7aece
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ react/dist
test-result.json
yarn-error.log
stats.html
bundle-stats*.html
.eslintcache
cypress/downloads/downloads.html
8 changes: 5 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const plugins = [
presets: ['@babel/preset-env'],
}),
terser({ toplevel: true }),
visualizer(),
]

/** @type {import('rollup').RollupOptions[]} */

const entrypoints = fs.readdirSync('./src/entrypoints').map((file) => {
const fileParts = file.split('.')
const extension = fileParts.pop()
// pop the extension
fileParts.pop()

let format = fileParts[fileParts.length - 1]
// NOTE: Sadly we can't just use the file extensions as tsc won't compile things correctly
Expand All @@ -37,6 +37,8 @@ const entrypoints = fs.readdirSync('./src/entrypoints').map((file) => {

const fileName = fileParts.join('.')

// we're allowed to console log in this file :)
// eslint-disable-next-line no-console
console.log(`Building ${fileName} in ${format} format`)
return {
input: `src/entrypoints/${file}`,
Expand All @@ -56,7 +58,7 @@ const entrypoints = fs.readdirSync('./src/entrypoints').map((file) => {
...(format === 'cjs' ? { exports: 'auto' } : {}),
},
],
plugins: [...plugins],
plugins: [...plugins, visualizer({ filename: `bundle-stats-${fileName}.html` })],
}
})

Expand Down

0 comments on commit 9b7aece

Please sign in to comment.