-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
60 lines (50 loc) · 1.38 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
57
58
59
60
/* jshint node: true */
'use strict';
const mergeTrees = require('broccoli-merge-trees');
const replace = require('broccoli-replace');
const staticPages = require('./lib/broccoli/broccoli-fastboot');
module.exports = {
name: 'ember-cli-static-site',
included (app) {
this._super.included.apply(this, arguments);
const defaultOptions = {
paths: [],
appendFileExtension: true,
includeClientScripts: false
};
this.options = app.options['ember-cli-static-site'] || {};
for (var option in defaultOptions) {
if (!this.options.hasOwnProperty(option)) {
this.options[option] = defaultOptions[option];
}
}
},
config () {
return {
staticSite: {
appendFileExtension: true
}
};
},
postprocessTree (type, tree) {
if (type === 'all') {
if (!this.options.includeClientScripts) {
const replaceOptions = {
files: ['index.html'],
patterns: [{
match: /<.*?script src=\"assets\/.*.js\".*?>.*?<\/.*?script.*?>/g,
replacement: ''
}]
};
tree = replace(tree, replaceOptions);
}
if (!this.app.options.__is_building_fastboot__) {
const staticTree = staticPages(tree, {
paths: this.options.paths
});
tree = mergeTrees([tree, staticTree], {overwrite: true});
}
}
return tree;
}
};