https://github.com/ddhp/remove-debug-loader
webpack loader to remove debug(or any method you defined) from your code
https://github.com/ddhp/remove-debug-loader
Last synced: 5 months ago
JSON representation
webpack loader to remove debug(or any method you defined) from your code
- Host: GitHub
- URL: https://github.com/ddhp/remove-debug-loader
- Owner: ddhp
- License: mit
- Created: 2017-10-18T10:24:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-06T08:35:29.000Z (over 7 years ago)
- Last Synced: 2025-09-29T06:51:29.229Z (9 months ago)
- Language: JavaScript
- Size: 73.2 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remove-debug-loader
[](https://www.npmjs.org/package/remove-debug-loader)
[](https://travis-ci.org/ddhp/remove-debug-loader)
[](https://codecov.io/github/ddhp/remove-debug-loader?branch=master)
[](https://dependencyci.com/github/ddhp/remove-debug-loader)
remove [debug](https://github.com/visionmedia/debug) from your code, by
- remove `require` and `import` debug
- remove method name - `debug`'s definition and invocation (name `debug` is default and can be config in loader options)
- remove custom modules(when you patched debug library)
## Installation
```
$ yarn add remove-debug-loader --dev
```
or
```
$ npm i --save-dev remove-debug-loader
```
## How to use
config `webpack.config.js` with:
```js
...
module: {
rules: [{
test: /\.js$/,
use: [{
loader: 'remove-debug-loader'
}]
}]
}
...
```
this would remove these patterns
requiring debug:
```js
const debug = require('debug')
```
also support `import` syntax:
```js
import debug from 'debug'
```
and debug methods
```js
debug('some log to log', 'stuff')
```
since [debug](https://github.com/visionmedia/debug) is log to stderr by default on server side (see [here](https://github.com/visionmedia/debug#output-streams)), we usually patch debug to another individual module
so you can add extra config to webpack if defining custom log method name and importing patched log library
e.g
```js
import patchedToStdout from './patchedToStdout'
const myLog = patchedToStdout('mynamespace')
myLog('some log to log', 'stuffs')
```
in this case, we need to remove importing patchedToStdout also `myLog`'s definition and invocation, so set loader's options `methodName` and `moduleName`:
```js
{
use: [{
loader: 'remove-debug-loader',
options: {
moduleName: ['patchedToStdout'],
methodName: ['myLog']
}
}]
}
```
those 2 options are array, so it supports as much as keyword you want to remove
## Known Issue
removing multi line debug invocation isn't support yet, i.e
```js
debug('a multi-line log message which would break code build',
'use remove-debug-loader with this precaution')
```
## License
see LICENSE