rollup-plugin-shell
raw JSON → 1.0.9 verified Mon Apr 27 auth: no javascript
Rollup plugin to execute arbitrary shell commands during the build process. Version 1.0.9 is the latest stable release. Allows specifying commands as strings or arrays and hooks into any Rollup build hook (default: generateBundle). Supports synchronous and asynchronous execution. Differentiators: minimal API, supports single or multiple commands, flexible hook integration. Designed for tasks like linting, copying files, or running dev servers.
Common errors
error TypeError: execute is not a function ↓
cause Using named import instead of default import.
fix
Use
import execute from 'rollup-plugin-shell' (without braces). error Error: Cannot find module 'rollup-plugin-shell' ↓
cause Package not installed or not installed as devDependency.
fix
Run
npm install rollup-plugin-shell --save-dev. Warnings
gotcha Using sync: true blocks the event loop; avoid in production builds for long-running commands. ↓
fix Set sync: false (default) to run commands asynchronously.
gotcha Commands are executed in the project root by default; relative paths may not work as expected. ↓
fix Use absolute paths or change cwd via ShellJS or other means before invoking.
gotcha No validation on commands array; empty array or missing commands option silently does nothing. ↓
fix Always provide at least one command string.
Install
npm install rollup-plugin-shell yarn add rollup-plugin-shell pnpm add rollup-plugin-shell Imports
- execute wrong
import { execute } from 'rollup-plugin-shell'correctimport execute from 'rollup-plugin-shell' - execute wrong
const { execute } = require('rollup-plugin-shell')correctconst execute = require('rollup-plugin-shell') - ShellPluginOptions
import type { ShellPluginOptions } from 'rollup-plugin-shell'
Quickstart
import execute from 'rollup-plugin-shell';
export default {
input: 'src/index.js',
output: {
file: 'dist/index.js',
},
plugins: [
execute({ commands: ['echo "Build complete"'], hook: 'buildStart' }),
],
};