The Repodog Rollup config.
# terminal
npm install @repodog/rollup-config rollup --save-dev
Rollup uses Babel or SWC for code compilation so you will also need to install @repodog/babel-config
or @repodog/swc-config
and the relevant peer dependencies.
// package.json
{
"scripts": {
"build": "rollup -c ./rollup.config.cjs"
}
}
// rollup.config.cjs
const rollupConfig = require('@repodog/rollup-config');
const babelConfig = require('@repodog/babel-config/rollup');
const { babel: babelPlugin } = require('@rollup/plugin-babel');
module.exports = {
...rollupConfig({ compiler: babelPlugin(babelConfig) }),
};
// rollup.config.cjs
const rollupConfig = require('@repodog/rollup-config');
const swcConfig = require('@repodog/swc-config');
const swcPlugin = require('@rollup/plugin-swc');
module.exports = {
...rollupConfig({ compiler: swcPlugin({ swc: swcConfig.ts }) }),
// or
...rollupConfig({ compiler: swcPlugin({ swc: swcConfig.js }) }),
};
Sets output.format
, directory name within ./dist
output, and the extension of the bundled output file. Default 'esm'
.
When set to 'production'
, terser mangles and compresses, the bundle analyser runs, and source maps are omitted.
You cam also use the environment variables outlined in @repodog/babel-config
or @repodog/swc-config
to control what is output.