Skip to content

Commit

Permalink
Split Rollup plugins into input (bundling) and output (generating)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jun 1, 2023
1 parent 74a578e commit f4eea59
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions rollup.release.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'
import { pkg } from 'govuk-frontend-config'
import { componentPathToModuleName } from 'govuk-frontend-lib/names'
import { defineConfig } from 'rollup'

import configFn from './rollup.umd.config.mjs'

/**
* Rollup config for GitHub release
*
* Universal Module Definition (UMD) bundle for browser <script>
* `window` globals and compatibility with CommonJS and AMD `require()`
*/
export default defineConfig((args) => {
const config = configFn(args)
export default defineConfig(({ i: input }) => ({
input,

/**
* Output options
*/
output: {
format: 'umd',
preserveModules: false,

// Add Terser minifier plugin
if ('plugins' in config && Array.isArray(config.plugins)) {
config.plugins.push(
/**
* Output plugins
*/
plugins: [
terser({
format: { comments: false },

Expand All @@ -28,8 +37,23 @@ export default defineConfig((args) => {
ecma: 5,
safari10: true
})
)
}
],

// Components are given names (e.g window.GOVUKFrontend.Accordion)
amd: { id: componentPathToModuleName(input) },
name: componentPathToModuleName(input)
},

/**
* Input plugins
*/
plugins: [
replace({
include: '**/common/govuk-frontend-version.mjs',
preventAssignment: true,

return config
})
// Add GOV.UK Frontend release version
development: pkg.version
})
]
}))

0 comments on commit f4eea59

Please sign in to comment.