Search code examples
sapui5ui5-tooling

How to reduce the number of files in the UI5 build output?


I have an OpenUI5 project that I build using the ui5-cli with the following command:

ui5 build self-contained --clean-dest --all

However, the build output includes the resources folder with many JavaScript files of UI5 Components that are not even used in my application, like CarouselLayout.js.

screenshot of project structure

The dependencies in my manifest.json file look like this:

"dependencies": {
    "minUI5Version": "1.118.0",
    "libs": {
        "sap.ui.core": {},
        "sap.ui.unified": {},
        "sap.m": {},
        "sap.f": {},
        "sap.ui.layout": {}
    }
},

How can I exclude all the JavaScript files that are not actually needed for my application from the build output?


Solution

  • Your build command is responsible for this. With your parameters, you tell your builder to include the whole framework locally. If you need it locally rather than bootstrap it from the CDN, you can remove the --all parameter at the end and see if that works out for you. The SAPUI5 builder is not able to go through your code and separate which single controls you are using and which not.

    In order to bootstrap the UI5 framework from the CDN, use the following line in your index.html:

    <script id="sap-ui-bootstrap"
        src="https://sdk.openui5.org/resources/sap-ui-core.js"
        ...