1 | # transform loader for webpack
|
2 |
|
3 | Use a browserify transforms as webpack-loader
|
4 |
|
5 | ## Usage
|
6 |
|
7 | [Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
|
8 |
|
9 | Pass the module name as query parameter.
|
10 |
|
11 | ``` javascript
|
12 | var x = require("!transform?brfs!./file.js");
|
13 | var x = require("!transform/cacheable?brfs!./file.js"); // cacheable version
|
14 | ```
|
15 |
|
16 | If you pass a number instead it will take the function from `this.options.transforms[number]`.
|
17 |
|
18 | ### Example webpack config
|
19 |
|
20 | ``` javascript
|
21 | module.exports = {
|
22 | module: {
|
23 | postLoaders: [
|
24 | {
|
25 | loader: "transform?brfs"
|
26 | }
|
27 | ]
|
28 | loaders: [
|
29 | {
|
30 | test: /\.coffee$/,
|
31 | loader: "transform/cacheable?coffeeify"
|
32 | },
|
33 | {
|
34 | test: /\.weirdjs$/,
|
35 | loader: "transform?0"
|
36 | }
|
37 | ]
|
38 | },
|
39 | transforms: [
|
40 | function(file) {
|
41 | return through(function(buf) {
|
42 | this.queue(buf.split("").map(function(s) {
|
43 | return String.fromCharCode(127-s.charCodeAt(0));
|
44 | }).join(""));
|
45 | }, function() { this.queue(null); });
|
46 | }
|
47 | ]
|
48 | };
|
49 | ```
|
50 |
|
51 |
|
52 | ## License
|
53 |
|
54 | MIT (http://www.opensource.org/licenses/mit-license.php)
|