forked from guardian/scribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlumbing.js
94 lines (83 loc) · 2.71 KB
/
Plumbing.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Warning: shameless self-plug!
* Plumber is the Guardian’s tool of choice for build systems.
* https://github.com/plumberjs/plumber
*/
var all = require('plumber-all');
// var bower = require('plumber-bower');
var glob = require('plumber-glob');
var requireJS = require('plumber-requirejs');
var uglifyJS = require('plumber-uglifyjs')();
var write = require('plumber-write');
module.exports = function (pipelines) {
var mainRequireJS = requireJS({
// FIXME: auto?
preserveLicenseComments: false,
paths: {
'event-emitter': '../bower_components/eventEmitter/EventEmitter',
'lodash-modern': '../bower_components/lodash-amd/modern'
},
shim: {
'event-emitter': {
exports: 'EventEmitter'
}
}
});
var sanitizerPluginRequireJS = requireJS({
// FIXME: auto?
preserveLicenseComments: false,
paths: {
'html-janitor': '../../bower_components/html-janitor/src/html-janitor'
}
});
var genericPluginRequireJS = requireJS({
// FIXME: auto?
preserveLicenseComments: false,
paths: {
'lodash-modern': '../../bower_components/lodash-amd/modern'
}
});
var toBuildDir = write('./build');
var writeBoth = all(
[uglifyJS, toBuildDir],
toBuildDir
);
pipelines['build'] = [
// TODO: use bower operation to find main of this component?
// As per: https://github.com/bower/bower/issues/1090
// bower('scribe'),
glob('./src/scribe.js'),
mainRequireJS,
// Send the resource along these branches
writeBoth
];
/**
* We define pipelines for building the non-core plugins. In the future the
* source files for these plugins will live in another repository.
*/
const genericPlugins = [
'scribe-plugin-blockquote-command',
'scribe-plugin-curly-quotes',
'scribe-plugin-heading-command',
'scribe-plugin-intelligent-unlink-command',
'scribe-plugin-keyboard-shortcuts',
'scribe-plugin-link-prompt-command',
'scribe-plugin-smart-lists',
'scribe-plugin-toolbar'
];
genericPlugins.forEach(function (pluginName) {
addPluginBuildPipeline(genericPluginRequireJS)(pluginName);
});
addPluginBuildPipeline(genericPluginRequireJS)('scribe-plugin-formatter-plain-text-convert-new-lines-to-html', '/formatters/plain-text');
addPluginBuildPipeline(sanitizerPluginRequireJS)('scribe-plugin-sanitizer');
function addPluginBuildPipeline(requireJSOperation) {
return function (name, path) {
pipelines['build:' + name] = [
glob('./src/plugins' + (path || '') + '/' + name + '.js'),
requireJSOperation,
// Send the resource along these branches
writeBoth
];
};
}
};