forked from CenterForOpenScience/ember-osf-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathember-cli-build.js
164 lines (151 loc) · 5.42 KB
/
ember-cli-build.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* eslint-env node */
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const Funnel = require('broccoli-funnel');
const { EMBER_ENV } = process.env;
const useCdn = EMBER_ENV === 'production';
function postProcess(content) {
return content.trim().replace(/^\s{20}/mg, '');
}
module.exports = function(defaults) {
const config = defaults.project.config(EMBER_ENV);
const handbookEnabled = config.engines.handbook.enabled;
const mirageEnabled = config['ember-cli-mirage'].enabled;
/*
* Options just used by child addons of the handbook engine. Some addons
* insist on looking to the root app config instead of their parent config.
*/
let handbookOptions = {};
if (handbookEnabled) {
handbookOptions = {
// ember-code-snippets
includeHighlightJS: false,
includeFileExtensionInSnippetNames: false,
snippetSearchPaths: ['lib/handbook/addon'],
snippetRegexes: {
begin: /{{#(?:docs-snippet|demo.example|demo.live-example)\sname=(?:"|')(\S+)(?:"|')/,
end: /{{\/(?:docs-snippet|demo.example|demo.live-example)}}/,
},
};
}
const app = new EmberApp(defaults, {
...handbookOptions,
hinting: config.lintOnBuild,
ace: {
modes: ['handlebars'],
},
addons: {
blacklist: [
'ember-cli-addon-docs', // Only included in the handbook engine
...Object.keys(config.engines).filter(
engineName => !config.engines[engineName].enabled,
),
],
},
'ember-bootstrap': {
bootstrapVersion: 3,
importBootstrapFont: true,
importBootstrapCSS: false,
},
'ember-cli-password-strength': {
bundleZxcvbn: !useCdn,
},
fingerprint: {
enabled: true,
exclude: [
'zxcvbn.js',
'assets/osf-assets',
// Exclude <engine-name>/config/environment.js from fingerprinting so it matches
// the engines exclude regex.
// https://github.com/ember-engines/ember-engines/blob/master/index.js#L10
'config/environment.js',
],
prepend: config.assetsPrefix,
},
sassOptions: {
includePaths: [
'node_modules/@centerforopenscience/osf-style/sass',
],
},
cssModules: {
headerModules: [
'ember-osf-web/styles/headers',
],
},
babel: {
sourceMaps: 'inline',
},
sourcemaps: {
enabled: config.sourcemapsEnabled,
extensions: ['js'],
},
inlineContent: {
assetsPrefix: {
content: config.assetsPrefix,
},
raven: {
enabled: useCdn,
content: `
<script src="https://cdn.ravenjs.com/3.22.1/ember/raven.min.js"></script>
<script>
var encodedConfig = document.head.querySelector("meta[name$='/config/environment']").content;
var config = JSON.parse(unescape(encodedConfig));
if (config.sentryDSN) {
Raven.config(config.sentryDSN, config.sentryOptions || {}).install();
}
</script>
`,
postProcess,
},
zxcvbn: {
enabled: useCdn,
/* eslint-disable max-len */
content: `
<script src="https://cdnjs.cloudflare.com/ajax/libs/zxcvbn/4.4.2/zxcvbn.js"
integrity="sha256-Znf8FdJF85f1LV0JmPOob5qudSrns8pLPZ6qkd/+F0o=
sha384-jhGcGHNZytnBnH1wbEM3KxJYyRDy9Q0QLKjE65xk+aMqXFCdvFuYIjzMWAAWBBtR
sha512-TZlMGFY9xKj38t/5m2FzJ+RM/aD5alMHDe26p0mYUMoCF5G7ibfHUQILq0qQPV3wlsnCwL+TPRNK4vIWGLOkUQ=="
crossorigin="anonymous">
</script>
`,
postProcess,
/* eslint-enable max-len */
},
},
'ember-cli-babel': {
includePolyfill: true,
},
assetLoader: {
generateURI(filePath) {
return config.assetsPrefix.replace(/\/$/, '') + filePath;
},
},
'ember-test-selectors': {
strip: false,
},
});
app.import('node_modules/dropzone/dist/dropzone.css');
app.import('node_modules/dropzone/dist/dropzone.js');
app.import({
test: 'vendor/ember/ember-template-compiler.js',
});
if (mirageEnabled) {
app.import('node_modules/seedrandom/seedrandom.min.js', {
using: [{ transformation: 'amd', as: 'seedrandom' }],
});
}
app.import('node_modules/keen-tracking/dist/keen-tracking.min.js', {
using: [{ transformation: 'amd', as: 'keen-tracking' }],
});
if (handbookEnabled) {
app.import('vendor/highlight.pack.js', {
using: [{ transformation: 'amd', as: 'highlight.js' }],
});
}
const assets = [
new Funnel('node_modules/@centerforopenscience/osf-style/img', {
srcDir: '/',
destDir: 'img',
}),
];
return app.toTree(assets);
};