-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
80 lines (63 loc) · 1.74 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict'
const validatePeerDependencies = require('validate-peer-dependencies')
const Funnel = require('broccoli-funnel')
const mergeTrees = require('broccoli-merge-trees')
const defaultOptions = {
enabled: true,
importAssets: true,
}
module.exports = {
name: require('./package').name,
options: {
'@embroider/macros': {
setOwnConfig: {},
},
},
_addonOptions: undefined,
getAddonOptions() {
if (this._addonOptions === undefined) {
this._addonOptions = Object.assign(
{},
defaultOptions,
this._findHost().options[this.name]
)
}
return this._addonOptions
},
included(parent) {
this._super.included.apply(this, arguments)
validatePeerDependencies(__dirname, {
resolvePackagePathFrom: this.parent.root,
})
this.options['@embroider/macros'].setOwnConfig.config =
this._findHost().project.config(process.env.EMBER_ENV)
this._findHost().options.fingerprint.exclude.push('tarteaucitron')
let addonOptions = this.getAddonOptions()
if (addonOptions.enabled) {
this.import('node_modules/tarteaucitronjs/tarteaucitron.js')
}
return parent
},
treeForPublic(tree) {
let trees = []
tree = this._super.treeForPublic.apply(this, arguments)
if (tree) {
trees.push(tree)
}
let addonOptions = this.getAddonOptions()
if (addonOptions.enabled && addonOptions.importAssets) {
trees = trees.concat([
new Funnel('node_modules/tarteaucitronjs', {
include: [
'css/*.css',
'lang/*.js',
'advertising.js',
'tarteaucitron.services.js',
],
destDir: 'assets/tarteaucitron',
}),
])
}
return mergeTrees(trees)
},
}