Skip to content
Snippets Groups Projects
Commit 028a0dce authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-11506 : Improve initial loading time of NG UI - initial version of...

SSDM-11506 : Improve initial loading time of NG UI - initial version of JavaScript bundle generation
parent e1831871
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
pushd $(dirname $0) > /dev/null
# create temporary output folder
rm -rvf output
mkdir output
# create a list of all *.js files from 'as', 'dss' and 'util' folders
find ../as ../dss ../util -name "*.js" | sed 's/^..\//"/g' | sed 's/.js$/",/g' > output/files.js
# create config files from their templates by replacing '__FILES__' with a content of 'files.js'
cat r.config.template.js | sed -e '\|__FILES__|{' -e 'r output/files.js' -e 'd' -e '}' > output/r.config.js
cat config.bundle.template.js | sed -e '\|__FILES__|{' -e 'r output/files.js' -e 'd' -e '}' > output/config.bundle.js
# create a JS bundle with all *.js files
node r.js -o output/r.config.js
# copy relevant output files to resource folder
cp output/config.bundle.js output/openbis.bundle.js ../
# remove temporary output folder
rm -rvf output
popd > /dev/null
\ No newline at end of file
var require = (function () {
var getBaseUrl = function () {
// To find where the V3 API has been loaded from we scan the script tags until finding this file
// This way is possible to load the V3 API from a separate domain
var scripts = document.getElementsByTagName('script')
var baseUrl = null
for (var sIdx = 0; sIdx < scripts.length; sIdx++) {
var src = scripts[sIdx].src
var substringEnd = -1
if ((substringEnd = src.indexOf('/api/v3/config.bundle.js')) > -1) {
baseUrl = src.substring(0, substringEnd + '/api/v3'.length)
}
}
return baseUrl
}
return {
baseUrl: getBaseUrl(),
bundles: {
'openbis.bundle': [
//
__FILES__
//
]
}
}
})()
({
baseUrl: '../../',
include: [
//
__FILES__
//
],
paths: {
jquery: 'lib/jquery/js/jquery',
stjs: 'lib/stjs/js/stjs',
underscore: 'lib/underscore/js/underscore',
moment: 'lib/moment/js/moment'
},
shim: {
stjs: {
exports: 'stjs',
deps: ['underscore']
},
underscore: {
exports: '_'
}
},
out: 'openbis.bundle.js',
optimize: 'none'
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment