diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/.gitignore b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/.gitignore index de4bae125ed0a67a7958b899044e8538ce1890e6..6f336601a44dff77cb6270c19e39e6de2c9a2510 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/.gitignore +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/.gitignore @@ -1,2 +1,2 @@ -config.bundle.js -openbis.bundle.js \ No newline at end of file +config.bundle.* +openbis.bundle.* \ No newline at end of file diff --git a/openbis_standard_technologies/resource/js/v3/build.sh b/openbis_standard_technologies/resource/js/v3/build.sh index c4e0122053bc46ca7c777df67478a2940a50bcbc..86ba22cd4e7db73def2779ab8e740da53582f94e 100755 --- a/openbis_standard_technologies/resource/js/v3/build.sh +++ b/openbis_standard_technologies/resource/js/v3/build.sh @@ -22,11 +22,13 @@ find ./as ./dss ./util -name "*.js" | sed 's/^.\//"/g' | sed 's/.js$/",/g' > $TE cd $CURRENT_DIR cat r.config.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/r.config.js cat config.bundle.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/config.bundle.js +cat config.bundle.min.template.js | sed -e '\|__FILES__|{' -e "r $TEMP_DIR/files.js" -e 'd' -e '}' > $TEMP_DIR/config.bundle.min.js # create a JS bundle using NodeJS binary installed by NodeJS gradle plugin -$OPENBIS_STANDARD_TECHNOLOGIES_DIR/node/nodejs/node-*/bin/node r.js -o $TEMP_DIR/r.config.js baseUrl=$V3_DIR +$OPENBIS_STANDARD_TECHNOLOGIES_DIR/node/nodejs/node-*/bin/node r.js -o $TEMP_DIR/r.config.js baseUrl=$V3_DIR optimize=none out=$TEMP_DIR/openbis.bundle.js +$OPENBIS_STANDARD_TECHNOLOGIES_DIR/node/nodejs/node-*/bin/node r.js -o $TEMP_DIR/r.config.js baseUrl=$V3_DIR optimize=uglify out=$TEMP_DIR/openbis.bundle.min.js # copy relevant files to the V3 public folder -cp $TEMP_DIR/config.bundle.js $TEMP_DIR/openbis.bundle.js $V3_DIR +cp $TEMP_DIR/config.bundle.js $TEMP_DIR/config.bundle.min.js $TEMP_DIR/openbis.bundle.js $TEMP_DIR/openbis.bundle.min.js $V3_DIR popd > /dev/null \ No newline at end of file diff --git a/openbis_standard_technologies/resource/js/v3/config.bundle.min.template.js b/openbis_standard_technologies/resource/js/v3/config.bundle.min.template.js new file mode 100644 index 0000000000000000000000000000000000000000..e731f42ffe2e6af15b0971edbc020b4fb039b3da --- /dev/null +++ b/openbis_standard_technologies/resource/js/v3/config.bundle.min.template.js @@ -0,0 +1,31 @@ +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.min.js')) > -1) { + baseUrl = src.substring(0, substringEnd + '/api/v3'.length) + } + } + return baseUrl + } + + return { + baseUrl: getBaseUrl(), + bundles: { + 'openbis.bundle.min': [ + 'jquery', + 'stjs', + 'underscore', + 'moment', + // + __FILES__ + // + ] + } + } +})() diff --git a/openbis_standard_technologies/resource/js/v3/r.config.template.js b/openbis_standard_technologies/resource/js/v3/r.config.template.js index 8e46ef030a6fe767e20c7cd58f0734a63c054420..fa748f0093f97506359534bfa03d2fcdff86c741 100644 --- a/openbis_standard_technologies/resource/js/v3/r.config.template.js +++ b/openbis_standard_technologies/resource/js/v3/r.config.template.js @@ -18,7 +18,5 @@ underscore: { exports: '_' } - }, - out: 'openbis.bundle.js', - optimize: 'none' + } })