Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.41 KB

README.md

File metadata and controls

60 lines (44 loc) · 1.41 KB

CI

Removes debug usage from your source code during webpack builds.

Usage

First npm install webpack-strip-debug-loader debug.

Debugging

You must use the wrapper around debug named Debug that this package exposes. All debug functions must be prefixed with debug or they will not be removed.

Do not:

  • Alias your import or require of Debug
  • Spread your require of Debug over more than one line
  • Wrap code with debug();like(this);debug() on the same line
  • Other crazy things

Just make simple debug statements.

import { Debug } from 'webpack-strip-debug-loader'

// Or use require if you prefer that
const { Debug } = require('webpack-strip-debug-loader')

const debug = Debug('feature')
const debugFoo = Debug('foo')

if (somethingOfInterestHappens) {
  debug('something happened')
}

if (foo) {
  debugFoo(
    'foo happened',
    foo,
    { ...foo }
    someFunc(foo)
  )
}

Stripping

To remove the logging and bundling of debug usage register this loader with webpack.

module: {
  rules: [
    {
        test: /\.js$/,
        exclude: /node_modules/,
        use: ['webpack-strip-debug-loader']
    }
  ]
}