heft-rollup-plugin
v0.1.0-beta.20250913100541
Published
Heft plugin for Rollup
Readme
heft-rollup-plugin
A Heft plugin for Rollup, similar to the official heft-webpack5-plugin.
Installation
npm install heft-rollup-plugin rollup --save-devUsage
1. Configure your heft.json
Add the plugin to your config/heft.json:
{
"$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json",
"heftPlugins": [
{
"plugin": "heft-rollup-plugin"
}
]
}2. Create a Rollup configuration
Create a rollup.config.js file in your project root:
export default {
input: 'src/index.ts',
output: {
file: 'dist/bundle.js',
format: 'esm'
}
};3. Plugin Options
You can configure the plugin by adding options in your heft.json:
{
"heftPlugins": [
{
"plugin": "heft-rollup-plugin",
"options": {
"configurationPath": "./custom-rollup.config.js",
"devConfigurationPath": "./rollup.dev.config.js"
}
}
]
}4. Available Parameters
--rollup:serve: Start in serve mode (watch mode only)
5. Configuration Files
The plugin will look for configuration files in this order:
Normal mode:
- Path specified in
configurationPathoption rollup.config.jsrollup.config.mjsrollup.config.ts
Serve mode:
- Path specified in
devConfigurationPathoption rollup.dev.config.jsrollup.dev.config.mjsrollup.dev.config.ts- Falls back to normal mode files
API
The plugin provides hooks for customization:
import type { IRollupPluginAccessor } from 'heft-rollup-plugin';
// Access the plugin via Heft
const rollupPlugin: IRollupPluginAccessor = heftSession.requestPlugin('rollup-plugin');
// Use hooks to customize behavior
rollupPlugin.hooks.onLoadConfiguration.tapPromise('MyPlugin', async () => {
// Return custom configuration
});
rollupPlugin.hooks.onConfigure.tapPromise('MyPlugin', async (configuration) => {
// Modify the configuration
});Development
Setup
# Install dependencies
npm install
# Build the plugin
npm run build
# Test the plugin
npm test
# Lint the code
npm run lintContributing
This project uses Conventional Commits for commit messages and automatic versioning.
Commit Message Format
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]Common types:
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testsbuild: Changes that affect the build system or external dependenciesci: Changes to CI configuration files and scriptschore: Other changes that don't modify src or test files
Making Commits
You can use commitizen for interactive commit messages:
npm run commitOr write conventional commit messages manually:
git commit -m "feat: add new rollup plugin feature"Release Process
This project uses automated releases:
- Beta releases: Automatically published to npm with
@nexttag when changes are merged tomainbranch - Stable releases: Published when a version tag is created using semantic-release
- Version bumping: Automatic based on conventional commit history
- Release notes: Auto-generated from conventional commits
Manual Release
To trigger a release manually:
# This will analyze commits and create a release if needed
npm run releaseLicense
MIT
