1 |
|
2 | 'use strict';
|
3 |
|
4 | const path = require('path');
|
5 | const getManifestConfiguration = require('./lib/get-manifest-configuration');
|
6 |
|
7 | const MANIFEST_NAME = 'manifest.webmanifest';
|
8 |
|
9 | module.exports = {
|
10 | name: 'ember-web-app',
|
11 |
|
12 | shouldIncludeChildAddon(childAddon) {
|
13 | if (childAddon.name === 'broccoli-asset-rev') {
|
14 | return false;
|
15 | }
|
16 |
|
17 | return this._super.shouldIncludeChildAddon.apply(this, arguments);
|
18 | },
|
19 |
|
20 | included(app) {
|
21 | this.app = app;
|
22 | app.options = app.options || {};
|
23 |
|
24 | this.addonBuildConfig = this.app.options['ember-web-app'] || {};
|
25 |
|
26 | if (!this._disabled()) {
|
27 | this._configureFingerprint();
|
28 | this.manifestConfiguration = getManifestConfiguration(this.app.project, this.app.env);
|
29 | }
|
30 |
|
31 | this._super.included.apply(this, arguments);
|
32 | },
|
33 |
|
34 | treeFor() {
|
35 | if (this._disabled()) {
|
36 | return;
|
37 | }
|
38 |
|
39 | return this._super.treeFor.apply(this, arguments);
|
40 | },
|
41 |
|
42 | treeForPublic() {
|
43 | const GenerateManifest = require('./lib/broccoli/generate-manifest-json');
|
44 |
|
45 | return new GenerateManifest(path.join(this.app.project.root, 'config'), {
|
46 | manifestName: MANIFEST_NAME,
|
47 | project: this.app.project,
|
48 | env: this.app.env,
|
49 | ui: this.ui
|
50 | });
|
51 | },
|
52 |
|
53 | contentFor(section, config) {
|
54 | if (this._disabled()) {
|
55 | return;
|
56 | }
|
57 |
|
58 | if (section === 'head') {
|
59 | let tags = [];
|
60 |
|
61 | tags = tags.concat(require('./lib/android-link-tags')(config, MANIFEST_NAME));
|
62 | tags = tags.concat(require('./lib/apple-link-tags')(this.manifestConfiguration, config));
|
63 | tags = tags.concat(require('./lib/favicon-link-tags')(this.manifestConfiguration, config));
|
64 |
|
65 | tags = tags.concat(require('./lib/android-meta-tags')(this.manifestConfiguration, config));
|
66 | tags = tags.concat(require('./lib/apple-meta-tags')(this.manifestConfiguration, config));
|
67 |
|
68 | return tags.join('\n');
|
69 | }
|
70 | },
|
71 |
|
72 | _configureFingerprint() {
|
73 | let configureFingerprint = require('./lib/configure-fingerprint');
|
74 | this.app.options.fingerprint = configureFingerprint(this.app.options.fingerprint, MANIFEST_NAME);
|
75 | },
|
76 |
|
77 | _disabled() {
|
78 | return this.addonBuildConfig.enabled === false;
|
79 | }
|
80 | };
|