rollup-plugin-strip-blocks

raw JSON →
1.0.3 verified Mon Apr 27 auth: no javascript

Rollup plugin that removes blocks of code delimited by special comment tags (/* develblock:start */ and /* develblock:end */ by default) from bundled output. Useful for stripping development-only code such as verbose console warnings, assertions, or debug logs from production builds. Current version 1.0.3 has no updates since release; low maintenance cadence. Differentiators: simple comment-based approach vs AST-based plugins like rollup-plugin-strip-code; no configuration required for basic use.

error Error: Cannot find module 'rollup-plugin-strip-blocks'
cause Package not installed or not resolved as a devDependency.
fix
Run: npm install --save-dev rollup-plugin-strip-blocks
error TypeError: stripblocks is not a function
cause Incorrect import style; using require() instead of import.
fix
Use: import stripblocks from 'rollup-plugin-strip-blocks'
error The plugin is not stripping my code blocks
cause Comment tags are not matched (e.g., missing / before *, or wrong case).
fix
Ensure blocks are wrapped with /* develblock:start */ and /* develblock:end */ (default). Check for typos.
gotcha Plugin does not remove the comment tags themselves; only the code between them is stripped. If you want the comments removed, use an additional plugin like rollup-plugin-terser.
fix Add a minifier or code removal plugin after strip-blocks.
gotcha The plugin only works with /* */ multi-line comments as delimiters, not // single-line comments.
fix Ensure your delimiters are block comments: /* develblock:start */ and /* develblock:end */.
deprecated The plugin uses Rollup's deprecated transform hook internally; may break in future Rollup versions.
fix Consider using rollup-plugin-strip-code as a more modern alternative.
gotcha Default comment tags are case-sensitive: /* develblock:start */, not /* DevelBlock:start */.
fix Use exactly the default tags or override with custom tags via options.
npm install rollup-plugin-strip-blocks
yarn add rollup-plugin-strip-blocks
pnpm add rollup-plugin-strip-blocks

Basic rollup config using the strip-blocks plugin to remove development blocks from the output bundle.

// rollup.config.js
import stripblocks from 'rollup-plugin-strip-blocks';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'es',
  },
  plugins: [
    stripblocks()
  ]
};