Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Minified *.properties and *.css are still requested #34

Closed
denisenepraunig opened this issue May 14, 2016 · 6 comments
Closed

Minified *.properties and *.css are still requested #34

denisenepraunig opened this issue May 14, 2016 · 6 comments

Comments

@denisenepraunig
Copy link

Hello,

I have a problem, when minifying with openui5_preload that the included properties and css files are still requested seperately, altough they are included in the Component-preload.js.

This is my folder structure:

|   Gruntfile.js
|   package.json           
\---webapp
    |   Component.js
    |   index.html
    |   manifest.json
    +---controller
    |       View1.controller.js  
    +---css
    |       style.css
    +---i18n
    |       i18n.properties
    +---model
    |       models.js
    \---view
            View1.view.xml

I have the following openui5_preload config:

openui5_preload: {
    component: {
        options: {
            resources: {
                cwd: 'webapp',
                prefix: 'test/minification',
                src: [
                    '**/*.js',
                    '**/*.fragment.html',
                    '**/*.fragment.json',
                    '**/*.fragment.xml',
                    '**/*.view.html',
                    '**/*.view.json',
                    '**/*.view.xml',
                    '**/*.properties',
                    '**/*.json',
                    '**/*.css'
                ]
            },
            dest: 'dist'
        },
        components: 'test/minification'
    }
}

which generates the following Component-preload.js:

jQuery.sap.registerPreloadedModules({
    "version": "2.0",
    "name": "test/minification/Component-preload",
    "modules": {
        "test/minification/Component.js": "sap.ui.define([\"sap/ui/...",
        "test/minification/controller/View1.controller.js": "sap.ui.define([\"sap...",
        "test/minification/model/models.js": "sap.ui.define([\"sap/ui/model...",
        "test/minification/view/View1.view.xml": "<mvc:View controllerName=\"test...",
        "test/minification/i18n/i18n.properties": "title=Title\nappTitle = App...",
        "test/minification/manifest.json": "{\"_version\":\"1.1.0\",\"sap.app...",
        "test/minification/css/style.css": "/* Enter your..."
    }
});

When I run the app, then the i18n.properties and style.css file are still requested seperately:

grunt_problem

What can I do to solve this issue? The app works when the properties and style files are not included (as you see in the plunk) - but it is still confusing that they are requested.

Here is my example app: (zip upload to issue did not work...)
https://www.dropbox.com/s/6nnieomdtn4eoq2/openui5_preload_example.zip?dl=0

Plunk here:
https://embed.plnkr.co/KWcMn1/

@js1972
Copy link

js1972 commented May 15, 2016

Notwithstanding issues with the grunt component, I know that UI5 repeatedly makes test calls to the host to find a more specific language file. I.e. First it will try and load an i18n_de.properties file, if it can't find that it tried with a less restrictive i18n.properties file and so on.
So even if you packaged up your i18n.properties file into the component preload I'm pretty sure ui5 will still make all those other calls looking for more specific language files, etc.

I wonder if there is a way to overload this process to have ui5 code ONLY look for the current locale language file?!?

@denisenepraunig
Copy link
Author

Oh well, the style.css must be loaded because it is linked in the html-file. My fault. The language stuff sounds reasonable.

@matz3
Copy link
Contributor

matz3 commented May 17, 2016

@denisenepraunig Although you can include files like *.css in your Component-preload.js they will NOT be considered when loading they in any way, e.g.:

  • <link> tag
  • jQuery.sap.includeStyleSheet
  • mainfest.json entry sap.ui5/resources/css

The last use case (or even the last two) could be supported in future, but are currently not.
So for now I would recommend to not include *.css files in your preload and load them separately.

@denisenepraunig
Copy link
Author

@matz3 Altough the i18n.properties file got packaed, SAPUI5 still tried to request it (and the other specific languages). In the SAP Web IDE build of the Component-preload.json the file is not included.
So - should we not include the properites files inside the preload file? Your default settings package them. According to my Plunker https://embed.plnkr.co/KWcMn1/ they are requested, but if they are not there, the translations are taken from the Component-preload.json.
Or should we include them and ignore that SAPUI5 still tries do load them?

@matz3
Copy link
Contributor

matz3 commented May 24, 2016

Thanks. I will have a look into this. But it doesn't seem to be correct to me. I think there is a difference between using bundleName and bundleUrl for the sap.ui.model.resource.ResourceModel.

Internal incident 1570819709 (and maybe even 1580111194) could be related.

As this is most probably an issue within openui5 not the grunt tooling I will close this issue in favor of a new one at https://github.com/SAP/openui5 after having a deeper look into the issue.

@matz3 matz3 self-assigned this May 24, 2016
@matz3
Copy link
Contributor

matz3 commented Oct 4, 2016

@denisenepraunig Finally I had a look into this again. The reason why the properties file is not taken from the preload in in your example for the first time (translation of manifest.json) but for the second (i18n model) is that the module name has to be guessed using the URL (see https://github.com/SAP/openui5/blob/4a7a346b40d0fe480f762154d4b05de276f75fe7/src/sap.ui.core/src/jquery.sap.global.js#L4348).
This only works in this case when the URL starts with a dot. Although it might be possible to fix this issue by improving the "guess" logic I don't think it would be worth. At least I've never heard of this issue before, so it should be very rare.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants