-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
56 lines (50 loc) · 1.48 KB
/
index.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
'use strict';
var collectImports = require('./lib/broccoli-collect-html-imports');
var stripImports = require('./lib/broccoli-strip-html-imports');
var vulcanize = require('broccoli-vulcanize');
var mergeTrees = require('broccoli-merge-trees');
/**
* options {
* extensions: ['html']
* outputFile: 'imports.html',
* overwrite: false,
* excludes: [/(^data:)|(^http[s]?:)|(^\/)/]
* abspath: '/webroot/',
* stripExcludes: false,
* stripComments: false,
* inlineScripts: false,
* inlineCss: false,
* implicitStrip: false
* }
*/
module.exports = function(inputTree, options) {
options = options || {};
var inputFiles = (options.extensions || []).map(function(ext) {
return '**/*.' + ext;
});
var outputFile = options.outputFile || 'vulcanized.html';
var excludes = options.excludes || [];
var collected = collectImports(inputTree, {
inputFiles: inputFiles,
outputFile: outputFile,
excludes: excludes
});
var vulcanized = vulcanize(collected, {
input: outputFile,
output: outputFile,
excludes: excludes,
abspath: options.abspath,
stripExcludes: options.stripExcludes,
stripComments: options.stripComments,
inlineScripts: options.inlineScripts,
inlineCss: options.inlineCss,
implicitStrip: options.implicitStrip
});
var stripped = stripImports(inputTree, {
extensions: options.extensions,
excludes: excludes
});
return mergeTrees([stripped, vulcanized], {
overwrite: options.overwrite
});
};