Skip to content

Commit

Permalink
chore: update rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmason committed Jul 1, 2022
1 parent 55f269c commit c6f7e51
Showing 1 changed file with 61 additions and 18 deletions.
79 changes: 61 additions & 18 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,68 @@ import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { babel } from '@rollup/plugin-babel'

const umd = { format: 'umd', name: 'A11yDialog', exports: 'default' }
const es = { format: 'es' }
const minify = {
plugins: [terser()],
banner: () => `/*! a11y-dialog ${pkg.version} — © Kitty Giraudel */`,
const babelCfg = {
babelHelpers: 'bundled',
assumptions: {
enumerableModuleMeta: true,
mutableTemplateObject: true,
noClassCalls: true,
noDocumentAll: true,
},
presets: [['@babel/preset-env', { targets: 'ie 11' }]],
}

export default {
input: 'src/a11y-dialog.js',
output: [
// Main files
{ file: 'dist/a11y-dialog.js', ...umd },
{ file: 'dist/a11y-dialog.esm.js', ...es },
// Minified versions
{ file: 'dist/a11y-dialog.min.js', ...umd, ...minify },
{ file: 'dist/a11y-dialog.esm.min.js', ...es, ...minify },
// Test version
{ file: 'cypress/fixtures/a11y-dialog.js', ...umd },
],
plugins: [nodeResolve(), commonjs({ include: 'node_modules/**' })],
const esmPlugins = [nodeResolve(), commonjs({ include: 'node_modules/**' })]

const umdPlugins = [...esmPlugins, babel(babelCfg)]

const minify = terser({
format: {
preamble: `/*! a11y-dialog ${pkg.version} — © Kitty Giraudel */`,
},
})

const umdCfg = {
format: 'umd',
name: 'A11yDialog',
exports: 'default',
}

export default [
{
input: 'src/a11y-dialog.js',
plugins: umdPlugins,
output: [
{
...umdCfg,
file: 'dist/a11y-dialog.js',
},
{
...umdCfg,
file: 'dist/a11y-dialog.min.js',
plugins: [minify],
},
{
...umdCfg,
file: 'cypress/fixtures/a11y-dialog.js',
},
],
},
{
input: 'src/a11y-dialog.js',
plugins: esmPlugins,
output: [
{
file: 'dist/a11y-dialog.esm.js',
format: 'esm',
},
{
file: 'dist/a11y-dialog.esm.min.js',
format: 'esm',
plugins: [minify],
},
],
},
]

0 comments on commit c6f7e51

Please sign in to comment.