forked from jherdman/ember-cli-trackjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (28 loc) · 1.01 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
/* jshint node: true */
'use strict';
module.exports = {
name: 'ember-cli-trackjs',
contentFor: function (type, config) {
var trackOpts;
var trackConfig;
var trackConfiguration;
var trackBoilerPlate;
var addonConfig;
if (type === 'head-footer') {
trackOpts = config.trackJs || {};
trackConfig = trackOpts.config || {};
trackConfiguration = '<script type="text/javascript" id="trackjs-configuration">window._trackJs = ' + JSON.stringify(trackConfig) + ';</script>';
if (trackOpts.url) {
trackBoilerPlate = '<script type="text/javascript" id="trackjs-boilerplate" src="' + trackOpts.url + '" crossorigin="anonymous"></script>';
}
return [trackConfiguration, trackBoilerPlate].join('\n');
}
},
included: function (app) {
this._super.included(app);
var options = app.options['ember-cli-trackjs'];
if (!(options && options.cdn) && (!process.env.EMBER_CLI_FASTBOOT)) {
app.import(app.bowerDirectory + '/trackjs/tracker.js');
}
}
};