-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (45 loc) · 1.3 KB
/
index.js
File metadata and controls
50 lines (45 loc) · 1.3 KB
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
'use strict';
module.exports = {
appEnv: null,
mirageConfig: null,
name: require('./package').name,
options: {
autoImport: {
webpack: {
module: {
rules: [
/* fixes issue with graphql-js's mjs entry */
/* see: https://github.com/graphql/graphql-js/issues/1272#issuecomment-393903706 */
{
test: /\.mjs$/,
include: /node_modules\/graphql/,
type: 'javascript/auto'
}
]
}
}
}
},
included(app) {
let config = app.project.config();
this.appEnv = config.environment;
this.mirageConfig = config['ember-cli-mirage'] || {};
this._super.included.apply(this, arguments);
},
treeForAddon() {
if (this._getShouldIncludeFiles()) {
return this._super.treeForAddon.apply(this, arguments);
}
},
_getShouldIncludeFiles() {
if (process.env.EMBER_CLI_FASTBOOT) {
return false;
}
let environment = this.appEnv;
let enabledInProd = environment === 'production' && this.mirageConfig.enabled;
let explicitExcludeFiles = this.mirageConfig.excludeFilesFromBuild;
let shouldIncludeFiles = enabledInProd || (environment &&
environment !== 'production' && explicitExcludeFiles !== true);
return shouldIncludeFiles;
}
};