-
Notifications
You must be signed in to change notification settings - Fork 1
/
browserify.plugin.js
64 lines (53 loc) · 2.38 KB
/
browserify.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Generated by CoffeeScript 1.9.0
(function() {
var browserify, fs, isArray,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
browserify = require('browserify');
fs = require('fs');
isArray = Array.isArray || function(value) {
return {}.toString.call(value) === '[object Array]';
};
module.exports = function(BasePlugin) {
var BrowserifybundlerPlugin;
return BrowserifybundlerPlugin = (function(_super) {
__extends(BrowserifybundlerPlugin, _super);
function BrowserifybundlerPlugin() {
return BrowserifybundlerPlugin.__super__.constructor.apply(this, arguments);
}
BrowserifybundlerPlugin.prototype.name = 'browserifybundler';
BrowserifybundlerPlugin.prototype.config = {
outFile: '/scripts/app.js',
inFiles: null,
excludes: ['jquery']
};
BrowserifybundlerPlugin.prototype.writeAfter = function() {
var b, destination, docpad, ignore, inFile, inputCount, outPath, rootPath, _i, _j, _len, _len1, _ref, _ref1, _ref2;
docpad = this.docpad;
_ref = docpad.getConfig(), rootPath = _ref.rootPath, outPath = _ref.outPath;
if (!isArray(this.config.inFiles)) {
this.config.inFiles = [this.config.inFiles];
}
if (!isArray(this.config.excludes)) {
this.config.excludes = [this.config.excludes];
}
b = browserify();
_ref1 = this.config.inFiles;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
inFile = _ref1[_i];
b.add("" + outPath + inFile);
}
_ref2 = this.config.excludes;
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
ignore = _ref2[_j];
b.ignore("" + ignore);
}
destination = fs.createWriteStream("" + outPath + this.config.outFile);
b.bundle().pipe(destination);
inputCount = this.config.inFiles.length;
return docpad.log('info', "Browserified " + inputCount + " file" + [inputCount > 1 ? 's' : void 0] + " to " + outPath + this.config.outFile);
};
return BrowserifybundlerPlugin;
})(BasePlugin);
};
}).call(this);