we are about to close a SAPUI5 application, one of the last steps is to make a Component-Preload.js
file to improve performance. I read different guides around
There are several main ways of doing it.
You can use SAP Web IDE to generate it. This assumes that you are using WebIDE to develop your application (which is not true based on your question). The regular version of WebIDE generates this file during the "client build" just before application deployment.
The "multi cloud" version of WebIDE can use a grunt build to do it. You can find more info here if you are interested: https://www.sap.com/developer/tutorials/webide-grunt-basic.html.
Use the new UI5 command line tools (https://npmjs.com/package/@ui5/cli):
npm i -g @ui5/cli
to install the tools globally.ui5 build preload
to build the preload.Use the @sap/grunt-sapui5-bestpractice-build
pre-configured grunt tasks. The downside is that they are more-or-less black boxes which do not allow that much customisation. You can find an example setup on SAP's GitHub repository jenkins-pipelines. In a nutshell:
.npmrc
file which adds the @sap npm registry: @sap:registry=https://npm.sap.com
.package.json
file. This file describes your application and your dependencies (runtime dependencies and dev dependencies; you will only have dev dependencies for now, as you just want to build your app). Make sure to mark the package as private. See the npm docu (at the end of the license chapter).npm i grunt -D
and npm i @sap/grunt-sapui5-bestpractice-build -D
.grunt
):module.exports = function (grunt) {
'use strict';
grunt.loadNpmTasks('@sap/grunt-sapui5-bestpractice-build');
grunt.registerTask('default', [
'lint',
'clean',
'build'
]);
};
You can use the official grunt_openui5 plugin to generate the preload file(s). In order to be able to do this, you need to have node installed:
npm init
).grunt
in the console. If you registered your build task as the grunt default task (like in the sample file: grunt.registerTask('default', [...]);
) then you just have to write grunt
. grunt
) inside your IDE as an external tool.Note that for most of the above methods, you need nodejs, which you can download and install from here: https://nodejs.org/en/download/.