Rollup Config Generator
Generate Rollup config files for libraries, React components, TypeScript, plugins, externals, inputs, outputs, CSS, and Vite options.
Quick Summary
What is this tool?
A Rollup Config Generator is an online tool that creates the configuration file (rollup.config.js) required by the Rollup module bundler. Rollup is widely considered the industry standard for bundling open-source libraries and NPM packages because it produces much flatter, smaller, and cleaner output than Webpack.
Instead of struggling with complex plugin chains (like figuring out how to combine node-resolve, CommonJS, and rollup-plugin-typescript2), this generator provides a robust baseline for building a rollup config for react library or a strict TypeScript package.
How to Use This Tool
- Define Inputs & Outputs — Set your entry point and select output formats like ES Modules (ESM) and CommonJS (CJS).
- Configure Externals — Specify peer dependencies (like React or Lodash) that should not be bundled.
- Select Plugins — Add plugins like @rollup/plugin-node-resolve, typescript2, and postcss.
- Generate & Download — Save the generated rollup.config.js to your project root.
- Update package.json — Ensure your package.json 'main', 'module', and 'exports' fields point to the generated outputs.
What This Tool Generates
rollup.config.js— The Rollup configuration exporting standard JS objects.rollup.config.mjs— An alternative extension explicitly forcing ES Modules.rollup.config.ts— A type-safe version for TypeScript developers.
Example Output Explanation
A standard rollup config js example for a TypeScript React library exporting both ESM and CJS:
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
const packageJson = require('./package.json');
export default {
input: 'src/index.ts',
output: [
{
file: packageJson.main,
format: 'cjs',
sourcemap: true,
},
{
file: packageJson.module,
format: 'esm',
sourcemap: true,
}
],
// Prevent bundling React into your library
external: ['react', 'react-dom'],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ useTsconfigDeclarationDir: true }),
postcss(),
]
};Best Practices
- Use Dual Outputs: When publishing to NPM, always configure Rollup to output both 'esm' (for modern bundlers like Vite/Webpack) and 'cjs' (for legacy Node.js environments).
- Externalize Peer Dependencies: Never bundle React, Vue, or large libraries into your package. Use the 'external' array or 'rollup-plugin-peer-deps-external' to keep your bundle size tiny.
- Use node-resolve: By default, Rollup doesn't know how to resolve dependencies from node_modules. You must always include '@rollup/plugin-node-resolve' if your library imports third-party packages you DO want to bundle.
Common Mistakes
- Missing CommonJS Plugin: Rollup only natively understands ES Modules (import/export). If you import a dependency that uses CommonJS (require/module.exports), Rollup will fail unless you include '@rollup/plugin-commonjs'.
- Forgetting Package.json Exports: Creating a dual ESM/CJS build in Rollup is useless if you don't update your package.json 'main', 'module', and 'exports' fields to point to the correct output files.
- Bundling CSS Incorrectly: If you are building a React component library, you must decide if you want Rollup to inject the CSS into the JS bundle (via 'rollup-plugin-postcss') or extract it to a separate .css file for the consumer to import manually.
Security Notes
- When bundling libraries, ensure you are not accidentally bundling sensitive configuration files or `.env` files into the NPM package. Double-check your output before running `npm publish`.
Testing Instructions
- Save the generated file as `rollup.config.js` in your project root.
- Install the required plugins listed in the generator output.
- Add `"build": "rollup -c"` to your package.json scripts.
- Run `npm run build` and inspect your output directory to ensure your library compiled correctly without bundling peer dependencies.
Frequently Asked Questions
What is a Rollup Config Generator?
How do I create rollup.config.js?
Should I use rollup.config.js, mjs, or ts?
How do I configure Rollup input and output?
What are Rollup external dependencies?
How do I create Rollup config for a React library?
How do I use Rollup with TypeScript?
What are Rollup options in Vite?
How We Keep Your Configs Safe & Valid
Built-in Error Checking
Every file is checked against official rules. We catch missing fields and bad syntax. YAML indentation errors are flagged right away. Kubernetes, Terraform, and Docker specs are all covered. API versions and labels are verified too. You get valid output every time you generate.
100% Private & Local
All tools run in your browser only. Your API keys never leave your machine. We do not use any tracking scripts. No data is sent to any server. Passwords and secrets stay on your device. Crypto operations use the Web Crypto API. Your privacy is fully protected at all times.
Secure Settings by Default
Configs use safe defaults out of the box. Containers run as non-root users. Root filesystems are set to read-only. Dangerous Linux capabilities are dropped. Network policies limit pod-to-pod traffic. TLS 1.3 is enabled for web servers. Security headers are added where needed.
Ready for CI/CD & Git
Output files are ready for your Git repo. Use them with ArgoCD, Flux, or GitHub Actions. Files use clear formatting and comments. Code review is easy for your team. Indentation and key order are consistent. Test in staging before going to production. Every file is clean and well-structured.
Infrastructure as Code
Store configs in Git alongside your code. Terraform modules include typed variables. Backend configs support remote state locking. Outputs work across multiple modules. Ansible playbooks use clear task steps. Chef and Puppet configs are also supported. Every file works with version control tools.
Monitoring & Tracing
Set up Prometheus with auto-discovery rules. Create Grafana dashboards with template variables. Add alerting rules with severity labels. Use OpenTelemetry for trace collection. Forward logs to Loki or Elasticsearch. Connect to Jaeger or Tempo for tracing. Monitor metrics, logs, and traces together.
Container & Docker Safety
Dockerfiles use multi-stage builds for small images. Base images are pinned to exact versions. Dev files are excluded from final images. Health checks are added for orchestrator use. Containers switch to non-root users. Docker Compose uses named volumes and networks. Resource limits are set in deploy configs.
Multiple Output Formats
Export as YAML, JSON, HCL, or TOML. Kubernetes uses YAML with proper separators. Terraform uses HCL with correct escaping. JSON output has consistent indentation. Copy to clipboard with one click. Preview output with syntax highlighting. Line numbers help you review quickly.
Related Tools
Vite Config Generator
Vite uses Rollup under the hood. Generate a Vite config for full web applications.
Webpack Config Generator
Compare Rollup with Webpack, the standard bundler for complex enterprise web apps.
Babel Config Generator
Configure Babel to run alongside Rollup for maximum browser compatibility.
package.json Generator
Ensure your package metadata is correct before publishing your Rollup-bundled library.