# strip-loader

> Webpack loader to strip arbitrary functions out of your production code.

Latest version **0.1.2** (published 2016-01-30) · 0 weekly downloads

## Install

```sh
npm install strip-loader
pnpm add strip-loader
yarn add strip-loader
bun add strip-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2016-01-30 |
| First published | 2015-01-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Rajiv Tirumalareddy |
| Maintainers | vijar |
| Keywords | webpack, strip |

## Links

- npm: https://www.npmjs.com/package/strip-loader
- Repository: git@github.com:yahoo/strip-loader
- Homepage: https://github.com/yahoo/strip-loader
- Issues: https://github.com/yahoo/strip-loader/issues
- npm.io page: https://npm.io/package/strip-loader

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^0.2.6

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2016-01-30
- 0.1.1 — 2016-01-09
- 0.1.0 — 2015-01-21

## README

# Strip Loader

[![npm version](https://badge.fury.io/js/strip-loader.svg)](http://badge.fury.io/js/strip-loader)
[![Build Status](https://travis-ci.org/yahoo/strip-loader.svg?branch=master)](https://travis-ci.org/yahoo/strip-loader)
[![Dependency Status](https://david-dm.org/yahoo/strip-loader.svg)](https://david-dm.org/yahoo/strip-loader)
[![devDependency Status](https://david-dm.org/yahoo/strip-loader/dev-status.svg)](https://david-dm.org/yahoo/strip-loader#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/yahoo/strip-loader/badge.png?branch=master)](https://coveralls.io/r/yahoo/strip-loader?branch=master)

Simple [Webpack](http://webpack.github.io/) loader to strip custom functions from your code. This can be useful if you want to use debug statements while developing your app but don't want this info exposed in your production code.


## Install

`npm install --save-dev strip-loader`

## Usage

In your client js source files:

```javascript

var debug = require('debug')('MyFile');

var makeFoo = function () {
    // The following two lines of code will be stripped with our webpack loader
    debug('makeFoo called');
    debug('makeFoo args', arguments);
    // This code would remain
    return 'Foo';
};

```

### Single function
In your webpack config:

```javascript
{
    module: {
        loaders: [
            { test: /\.js$/, loader: "strip-loader?strip[]=debug" }
        ]
    }
};
```

### Multiple functions
In your webpack config:

```javascript
{
    module: {
        loaders: [
            { test: /\.js$/, loader: "strip-loader?strip[]=debug,strip[]=console.log" }
        ]
    }
};
```

### Use as library
In your webpack config:

```javascript
var WebpackStrip = require('strip-loader');

var webpackConfig = {
    module: {
        loaders: [
            { test: /\.js$/, loader: WebpackStrip.loader('debug', 'console.log') }
        ]
    }
};
```

### Replace unused module

So far we've removed the calls to the debug function, but your app still requires the `debug` module in the final bundle. Use the [`NormalModuleReplacementPlugin`](http://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin) to replace it with an empty function:

```javascript
// webpack config
{
    plugins: [
        new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/emptyDebug.js'),
    ]
}

// emptyDebug.js
module.exports = function() { return new Function(); };
```



## License

This software is free to use under the Yahoo! Inc. BSD license.
See the [LICENSE file][] for license text and copyright information.

[LICENSE file]: https://github.com/yahoo/strip-loader/blob/master/LICENSE.md

---
_Source: https://npm.io/package/strip-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
