Registry / devops / rollup-plugin-preprocess

rollup-plugin-preprocess

JSON →
library0.0.4jsnpmunverified

A Rollup plugin that integrates the Preprocess library to conditionally include or exclude parts of files (HTML, JS, etc.) based on a user-defined context (e.g., DEBUG flags). The latest stable version is 0.0.4 (released November 2016). Development appears to be stalled with no recent releases or maintenance; this plugin is a thin wrapper around the `preprocess` package for Rollup build pipelines. Alternatives include `@rollup/plugin-replace` or direct use of `preprocess` with other Rollup hooks. The plugin supports simple context-based preprocessing but lacks extensive documentation and has limited adoption.

npm install rollup-plugin-preprocess
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-PREP
R
rollup-plugin-preprocess
devopsjavascriptv0.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import preprocess from 'rollup-plugin-preprocess'
const preprocess = require('rollup-plugin-preprocess').default
This package uses a CommonJS default export; with ESM, import default directly. In CJS, use require('rollup-plugin-preprocess')() — note no .default.
RollupPluginPreprocess
import RollupPluginPreprocess from 'rollup-plugin-preprocess'
import { RollupPluginPreprocess } from 'rollup-plugin-preprocess'
There is no named export; the entire module exports a single function. Using curly braces will result in undefined.

Shows how to configure the plugin with a context object and use preprocess directives in source files.

// rollup.config.js import preprocess from 'rollup-plugin-preprocess'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife' }, plugins: [ preprocess({ context: { DEBUG: process.env.DEBUG === 'true', VERSION: '1.0.0' } }) ] }; // In your source code: // @if DEBUG console.log('Debug mode'); // @endif // @echo VERSION
Debug
Known issues
deprecatedThis package has not been updated since 2016 and is essentially unmaintained. Consider using modern alternatives like @rollup/plugin-replace.
fix
Migrate to @rollup/plugin-replace or use the preprocess library directly with a custom Rollup plugin.
affects: *
gotchaThe plugin does not handle TypeScript or Vue files out-of-the-box; you may need to adjust the include/exclude filter.
fix
Manually specify the include and exclude options in the plugin configuration.
affects: >=0.0.1
gotchaThe context object is not deeply merged; only top-level properties are available in preprocess directives.
fix
Pass nested values as flat keys or use a string expression that evaluates in the preprocess context.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'rollup-pluginutils'
Missing dependency rollup-pluginutils which is a peer dependency.
fix
npm install rollup-pluginutils --save-dev
TypeError: preprocess is not a function
Using named import when only default export exists.
fix
Use import preprocess from 'rollup-plugin-preprocess' instead of import { preprocess } from 'rollup-plugin-preprocess'
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
preprocessrequiredCore preprocessing library for evaluating conditional comments in files.
rollup-pluginutilsrequiredProvides utility functions like createFilter for Rollup plugins.
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-preprocess — npm install rollup-plugin-preprocess · libregistry