Registry / devops / webpack-remove-code-blocks

webpack-remove-code-blocks

JSON →
library0.10.1jsnpmunverified

A webpack loader plugin that removes blocks of code marked with special comment labels (e.g., `/* devblock:start */.../* devblock:end */`) from files processed by webpack. Current stable version 0.10.1 supports webpack >=3.0.0 and Node.js >=18. It allows multiple named block definitions, optional replacement text, and modes to skip removal based on webpack's `mode` option. Differentiates from alternatives by supporting custom labels, prefixes, and suffixes, and being actively maintained.

npm install webpack-remove-code-blocks
INSTALL
IMPORT
SIG · WEBPACK-REMOVE-COD
W
webpack-remove-code-blocks
devopsjavascriptv0.10.1
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default export (plugin instance) loader function
module.exports = { module: { rules: [ { test: /\.js$/, use: 'webpack-remove-code-blocks' } ] } }
Use via require('webpack-remove-code-blocks') as a constructor or class.
The package exports a loader function directly, not a class or object. Use it as a string or object in webpack rules.
loader path in webpack config
loader: 'webpack-remove-code-blocks'
loader: require.resolve('webpack-remove-code-blocks')
The loader name is a string; webpack resolves it from node_modules.
options object for custom blocks
options: { blocks: ['debug', { start: 'devblock_start', end: 'devblock_end', prefix: '/*', suffix: '*/' }] }
Options passed as a separate argument or via plugin syntax.
Options are passed as an object under the `options` key in the rule's use array.

Shows basic webpack configuration to remove code blocks labeled `devblock` from .js files, with input and expected output.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: [ { loader: 'webpack-remove-code-blocks', options: { blocks: ['devblock', 'debug'] } } ] } ] } }; // Input file: app.js /* devblock:start */ console.log('remove me'); /* devblock:end */ console.log('keep me'); // Output: 'keep me' block only
Debug
Known issues
breakingVersion 0.9.0 drops support for Node.js 16 and contains massive refactoring; may break older configs.
fix
Upgrade to v0.10.1 or ensure Node.js >=18. Check block definitions as option format may have changed.
affects: >=0.9.0 <0.10.0
breakingVersion 0.9.0 changes versioning and is described as a 'candidate for the initial release'; may introduce incompatibilities with earlier v0.1.x.
fix
Review changelog for breaking changes; update block options if using custom start/end labels.
affects: >=0.9.0 <0.10.0
deprecatedNode.js 16 support dropped in v0.9.0.
fix
Use Node.js >=18 for v0.9.0+.
affects: >=0.9.0
gotchaLoader name is 'webpack-remove-code-blocks' not 'webpack-remove-block' (similar package).
fix
Verify spelling in webpack config; use 'webpack-remove-code-blocks'.
affects: all
gotchaIf no `blocks` option provided, default blocks may not be defined; the loader may process nothing.
fix
Always specify at least one block label (e.g., `blocks: ['devblock']`).
affects: >=0.1.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'webpack-remove-code-blocks'
Loader name typo or missing npm install.
fix
Run `npm install --save-dev webpack-remove-code-blocks` and ensure the loader name is exactly 'webpack-remove-code-blocks'.
TypeError: loader is not a function
Using require() result as a constructor or plugin instead of a loader string.
fix
Use loader: 'webpack-remove-code-blocks' in the webpack rule, not as a plugin or function.
No blocks removed from output
Missing `blocks` options or wrong comment syntax.
fix
Add `options: { blocks: ['devblock'] }` to the rule and use correct comment syntax: `/* devblock:start */ ... /* devblock:end */`.
Error: Mode removal not working
Mode option expects array of webpack mode strings; may be misconfigured.
fix
Check docs: mode value should be an array like `['development']` to skip removal in that mode.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
webpackrequiredPeer dependency: the plugin runs as a webpack loader; requires webpack >=3.0.0.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
webpack-remove-code-blocks — npm install webpack-remove-code-blocks · libregistry