This repository has been archived by the owner on Jan 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rajiv Tirumalareddy
committed
Jan 20, 2015
1 parent
076fdea
commit f16f976
Showing
9 changed files
with
143 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
tests/fixtures/app/bundle.js | ||
/artifacts/ | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/artifacts/ | ||
/tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Contributing Code to `webpack-strip` | ||
------------------------------- | ||
|
||
Please be sure to sign our [CLA][] before you submit pull requests or otherwise contribute to `webpack-strip`. This protects developers, who rely on [BSD license][]. | ||
|
||
[BSD license]: https://github.com/yahoo/webpack-strip/blob/master/LICENSE.md | ||
[CLA]: https://yahoocla.herokuapp.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Software License Agreement (BSD License) | ||
======================================== | ||
|
||
Copyright (c) 2015, Yahoo! Inc. All rights reserved. | ||
---------------------------------------------------- | ||
|
||
Redistribution and use of this software in source and binary forms, with or | ||
without modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name of Yahoo! Inc. nor the names of YUI's contributors may be | ||
used to endorse or promote products derived from this software without | ||
specific prior written permission of Yahoo! Inc. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Webpack Strip | ||
============= | ||
|
||
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. | ||
|
||
##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: "webpack-strip?strip[]=debug" } | ||
] | ||
} | ||
}; | ||
``` | ||
|
||
### Multiple functions | ||
In your webpack config: | ||
|
||
```javascript | ||
{ | ||
module: { | ||
loaders: [ | ||
{ test: /\.js$/, loader: "webpack-strip?strip[]=debug,strip[]=console.log" } | ||
] | ||
} | ||
}; | ||
``` | ||
|
||
### Use as library | ||
In your webpack config: | ||
|
||
```javascript | ||
var WebpackStrip = require('webpack-strip') | ||
{ | ||
module: { | ||
loaders: [ | ||
{ test: /\.js$/, loader: WebpackStrip.loader('debug', 'console.log') } | ||
] | ||
} | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{ | ||
"name": "webpack-strip", | ||
"version": "0.0.1", | ||
"description": "Webpack loader to strip arbitrary functions out of your code.", | ||
"version": "0.1.0", | ||
"description": "Webpack loader to strip arbitrary functions out of your production code.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"cover": "node node_modules/istanbul/lib/cli.js cover --dir artifacts -- ./node_modules/mocha/bin/_mocha tests/unit/ --recursive --reporter spec", | ||
"lint": "./node_modules/.bin/jshint lib tests", | ||
"test": "mocha tests/unit --recursive --reporter spec" | ||
}, | ||
"keywords": [ | ||
|
@@ -13,10 +15,21 @@ | |
"author": "Rajiv Tirumalareddy <[email protected]>", | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"istanbul": "^0.3.5", | ||
"jshint": "^2.5.11", | ||
"mocha": "^2.1.0", | ||
"webpack": "^1.4.15" | ||
}, | ||
"dependencies": { | ||
"loader-utils": "^0.2.6" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "BSD", | ||
"url": "https://github.com/yahoo/webpack-strip/blob/master/LICENSE.md" | ||
} | ||
], | ||
"jshintConfig": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
/** | ||
* Copyright 2015, Yahoo! Inc. | ||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
*/ | ||
|
||
var makeFoo = function (bar, baz) { | ||
// The following 2 lines of code will be stripped with our webpack loader | ||
assert(1!==2, '1 must not equal 2'); | ||
debug('1 must not equal 2'); | ||
console.log('some debug info'); | ||
debug('better debug info'); | ||
// This code would remain | ||
return new Foo(bar, baz); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters