forked from rancher/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathember-cli-build.js
More file actions
262 lines (244 loc) · 10.3 KB
/
Copy pathember-cli-build.js
File metadata and controls
262 lines (244 loc) · 10.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var BroccoliFunnel = require('broccoli-funnel');
var BroccoliMergeTrees = require('broccoli-merge-trees');
var Funnel = BroccoliFunnel.default || BroccoliFunnel;
var mergeTrees = BroccoliMergeTrees.default || BroccoliMergeTrees;
var util = require('util');
var env = EmberApp.env();
var dartSass = require('sass');
var TranslationJsonTree = require('./lib/translation-json-tree');
var NormalizeTemplateModuleNameWebpackPlugin = require('./lib/normalize-template-module-name-webpack-plugin');
module.exports = function(defaults) {
// Pull in a few useful environment settings for index.html to use
var appConfig = require('./config/environment')(env).APP;
var inline = {};
var themeCssOutputPaths = {
'app-light': '/assets/ui-light.css',
'app-dark': '/assets/ui-dark.css'
};
['version', 'appName', 'baseAssets'].forEach(function(key) {
var val = appConfig[key];
if (val) {
inline[key] = {
content: val
};
}
});
var app = new EmberApp(defaults, {
// The legacy Ember application resolves internal imports through the neutral
// `ui/` module prefix. Keep that runtime contract while package metadata uses
// the public @pasturestack/web-console identity.
name: 'ui',
storeConfigInMeta: false,
inlineContent: inline,
sassOptions: {
implementation: dartSass
},
outputPaths: {
app: {
js: '/assets/ui.js',
css: themeCssOutputPaths
}
},
nodeAssets: {
'lacsso': {
import: ['lacsso.css']
}
},
// ember-auto-import stages two generated entry modules in a temporary
// Broccoli directory. Webpack's production default hashes those absolute
// paths into module IDs, so identical clean builds can receive different
// chunk fingerprints. Natural entry-module IDs are stable for an identical
// graph, while deterministic chunk IDs retain cache-safe output names.
autoImport: {
webpack: {
// Inline-template compilation otherwise records the absolute build
// workspace in module metadata. Inject the normalizer after Ember Auto
// Import assembles its strict Babel rules so clean production builds are
// byte-for-byte reproducible and do not disclose a builder path.
plugins: [new NormalizeTemplateModuleNameWebpackPlugin()],
optimization: {
moduleIds: 'natural',
chunkIds: 'deterministic'
}
}
},
fingerprint: {
exclude: [
// These can be bind-mounted in
'assets/images/logos',
// These get version added to the query string so JS doesn't have to know the fingerprint
'assets/intl',
'ui-light.css', 'ui-light.rtl.css',
'ui-dark.css', 'ui-dark.rtl.css',
'ui.css', 'ui.rtl.css',
'vendor.css', 'vendor.rtl.css',
],
extensions: (appConfig.fingerprint === 'no' ? [] : ['js', 'css', 'png', 'jpg', 'gif', 'svg', 'map', 'woff', 'woff2', 'ttf']),
},
sourcemaps: {
// Production artifacts are public and must not expose application source.
// Keep maps for development and tests, where they remain useful for
// diagnostics, and omit them from release candidates.
enabled: env !== 'production',
extensions: ['js']
},
});
// Ember CLI 6.12 recreates outputPaths after merging constructor options.
// Mutate the active CSS map in place because the default packager and the
// Sass preprocessor both retain this exact object reference. Replacing the
// object would leave the packager pointing at the empty app.scss output and
// silently omit the two runtime theme stylesheets.
var activeCssOutputPaths = app.options.outputPaths.app.css;
Object.keys(activeCssOutputPaths).forEach(function(entry) {
delete activeCssOutputPaths[entry];
});
Object.assign(activeCssOutputPaths, themeCssOutputPaths);
// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.
// Tests now bundle QUnit directly instead of pulling the legacy
// ember-cli-qunit -> ember-qunit -> ember-test-helpers chain.
app.import('vendor/jquery/jquery.js');
app.import('node_modules/qunit/qunit/qunit.css', { type: 'test' });
app.import('node_modules/qunit/qunit/qunit.js', { type: 'test' });
app.import('vendor/qunit-module-shim.js', { type: 'test' });
app.import('vendor/ember/ember-global-compat.js');
app.import('node_modules/@xterm/xterm/css/xterm.css');
app.import('node_modules/@xterm/xterm/lib/xterm.js');
app.import('node_modules/@xterm/addon-fit/lib/addon-fit.js');
// Bootstrap 3 is out of support. Keep its reviewed styles during the
// compatibility migration, but only ship the two JavaScript behaviours the
// console still uses. In particular, do not re-introduce button.js,
// tooltip.js, popover.js, or the aggregate bootstrap.js bundle.
app.import('vendor/bootstrap-sass/assets/javascripts/bootstrap/transition.js');
app.import('vendor/bootstrap-sass/assets/javascripts/bootstrap/collapse.js');
app.import('vendor/bootstrap-sass/assets/javascripts/bootstrap/dropdown.js');
app.import('node_modules/jgrowl/jquery.jgrowl.js');
app.import('node_modules/jgrowl/jquery.jgrowl.css');
app.import('node_modules/jquery.cookie/jquery.cookie.js');
app.import('node_modules/d3/d3.js');
app.import('node_modules/c3/c3.js');
app.import('node_modules/c3/c3.css');
//app.import('vendor/term.js/src/term.js');
//app.import('bower_components/xterm.js/src/xterm.css');
app.import('vendor/bootstrap-multiselect/bootstrap-multiselect.js');
app.import('vendor/bootstrap-multiselect/bootstrap-multiselect.css');
app.import('node_modules/prismjs/prism.js');
app.import('node_modules/prismjs/components/prism-yaml.js');
app.import('node_modules/prismjs/components/prism-bash.js');
app.import('node_modules/lodash/lodash.js');
app.import('node_modules/graphlib/dist/graphlib.core.js');
app.import('node_modules/dagre/dist/dagre.core.js');
app.import('node_modules/async/dist/async.js');
app.import('vendor/position-calculator.js');
app.import('vendor/aws-sdk-ec2.js');
app.import('node_modules/identicon.js/pnglib.js');
app.import('node_modules/identicon.js/identicon.js');
app.import('node_modules/md5-jkmyers/md5.js');
app.import('vendor/dagre-d3/dagre-d3.core.js');
app.import('vendor/novnc.js');
app.import('node_modules/commonmark/dist/commonmark.js');
// Generate TOTP enrollment QR codes entirely in the browser. The
// provisioning secret never leaves the PastureStack origin.
app.import('node_modules/qrcode-generator/dist/qrcode.js');
app.import('node_modules/moment/moment.js');
app.import('node_modules/moment/locale/de.js');
app.import('node_modules/moment/locale/fa.js');
app.import('node_modules/moment/locale/fr.js');
app.import('node_modules/moment/locale/hu.js');
app.import('node_modules/moment/locale/ja.js');
app.import('node_modules/moment/locale/ko.js');
app.import('node_modules/moment/locale/pt-br.js');
app.import('node_modules/moment/locale/ru.js');
app.import('node_modules/moment/locale/tl-ph.js');
app.import('node_modules/moment/locale/uk.js');
app.import('node_modules/moment/locale/zh-cn.js');
app.import('node_modules/moment/locale/zh-tw.js');
app.import('vendor/moment-default-locale.js');
app.import('vendor/ansi-up/ansi-up-global.js');
app.import('vendor/semver/semver-global.js');
app.import('vendor/shell-quote/shell-quote-global.js');
app.import('vendor/icons/style.css');
app.import('vendor/icons/fonts/pasturestack-icons.svg', {
destDir: 'assets/fonts'
});
app.import('vendor/icons/fonts/pasturestack-icons.ttf', {
destDir: 'assets/fonts'
});
app.import('vendor/icons/fonts/pasturestack-icons.woff', {
destDir: 'assets/fonts'
});
app.import('vendor/icons/fonts/pasturestack-icons.woff2', {
destDir: 'assets/fonts'
});
// Google Font Downloader thing: https://google-webfonts-helper.herokuapp.com/
app.import('vendor/lato/lato-v11-latin-300.woff', {
destDir: 'assets/fonts'
});
app.import('vendor/lato/lato-v11-latin-300.woff2', {
destDir: 'assets/fonts'
});
app.import('vendor/lato/lato-v11-latin-700.woff', {
destDir: 'assets/fonts'
});
app.import('vendor/lato/lato-v11-latin-700.woff2', {
destDir: 'assets/fonts'
});
app.import('vendor/lato/lato-v11-latin-regular.woff', {
destDir: 'assets/fonts'
});
app.import('vendor/lato/lato-v11-latin-regular.woff2', {
destDir: 'assets/fonts'
});
var translationSource = new Funnel('translations', {
include: ['*.yaml']
});
var translationJson = new TranslationJsonTree(translationSource);
var emberLegalSource = new Funnel('vendor/ember', {
include: ['LICENSE', 'UPSTREAM.md'],
destDir: 'licenses/ember'
});
var emberFetchLegalSource = new Funnel('vendor/ember-fetch-compat', {
include: ['LICENSE.md', 'UPSTREAM.md'],
destDir: 'licenses/ember-fetch'
});
var emberPowerSelectLegalSource = new Funnel('vendor/ember-power-select', {
include: ['LICENSE.md', 'UPSTREAM.md'],
destDir: 'licenses/ember-power-select'
});
var emberBasicDropdownLegalSource = new Funnel('vendor/ember-basic-dropdown', {
include: ['LICENSE.md', 'UPSTREAM.md'],
destDir: 'licenses/ember-basic-dropdown'
});
var runtimeLegalPackages = [
'ember-power-select',
'ember-basic-dropdown',
'ember-concurrency',
'ember-modifier'
];
var runtimeLegalSources = runtimeLegalPackages.map(function(packageName) {
return new Funnel('vendor/runtime-licenses/' + packageName, {
include: ['LICENSE.md', 'UPSTREAM.md'],
destDir: 'licenses/runtime/' + packageName
});
});
return mergeTrees([
app.toTree(),
translationJson,
emberLegalSource,
emberFetchLegalSource,
emberPowerSelectLegalSource,
emberBasicDropdownLegalSource
].concat(runtimeLegalSources), {overwrite: true});
};