SAP-archive / grunt-openui5

Grunt tasks around OpenUI5
Apache License 2.0
90 stars 34 forks source link

When prefix is left blank, for preload task, task won't run #16

Closed hagen closed 4 years ago

hagen commented 8 years ago

Hi there,

I have similar grunt config to your sample-app, but use different directory names:

grunt.initConfig({

    dir: {
        src: 'src',
        dist: 'dist'
    },

    openui5_preload: {
        component: {
            options: {
                resources: {
                    cwd: '<%= dir.src %>',
                    prefix: ''
                },
                dest: '<%= dir.dist %>'
            },
            components: true
        }
    },

When run, I get: Warning: No files found for pattern(s): "/**"! Use --force to continue.

I don't need/want a prefix. I've also noticed that if I start adding in prefixes to keep the warning quiet, the app doesn't use the Component-preload.js, it still reads in each of the Controllers/Views.

Snippet of my index.html:

<script
    type="text/javascript"
    id="sap-ui-bootstrap"
    src="sdk/openui5-runtime-1.30.8/resources/sap-ui-core.js"
    data-sap-ui-theme="sap_bluecrystal"
    data-sap-ui-xx-bindingSyntax="complex"
    data-sap-ui-libs="sap.m"
    data-sap-ui-resourceroots='{
            "com.ffa.dash": "./",
            "view" : "./view",
            "util" : "./util",
            "thirdparty" : "./thirdparty"
    }'>
</script>

Directory structure: app -- util -- view ---- App.controller.js ---- App.view.xml

Declaration from App controller:

jQuery.sap.declare("view.App");

// Provides controller view.App
sap.ui.define(['jquery.sap.global', 'com/ffa/dash/util/Controller'],
function(jQuery, Controller) {
"use strict";

var App = Controller.extend("view.App", /** @lends view.App.prototype */ {

});

    return App;

}, /* bExport= */ true);
matz3 commented 8 years ago

Could you please provide the complete folder structure (including Component.js)? It might be a problem that you have multiple resourceroots which do not match with the Component's namespace.

hagen commented 8 years ago

Certainly

image

matz3 commented 8 years ago

Okay, so the issue is that all your modules (views, controller, ...) have to be in the same namespace as the Component is. This is the reason why it did not use the preload. So the easiest solution would be to remove the view, util and thirdparty resourceroot and adopt the module names to com.ffa.dash.view.*, com.ffa.dash.util.* and com.ffa.dash.thirdparty.*

Furthermore you need to configure the prefix with com/ffa/dash as this seems to be the namespace of your Component, which is not reflected by the folder structure.

hagen commented 8 years ago

Thank you for the advice @matz3. I have done as you suggested, and the preload builds nicely. My prefix is com/ffa/hpc, and is the namespace used across all Controllers and Views, and is the only resource root used. The application loads and runs without issue. I have one further question however: the resources loaded by the preload file are located in a folder 'undefined', in the web inspector (Chrome). Is this to be expected, or is something still not quite right? See below...

image

matz3 commented 8 years ago

This looks like an issue. I will look into it, thanks for reporting!

hagen commented 7 years ago

Hi @matz3 we're you able to look into the undefined/ namespace prefix at all? It doesn't affect operation of Component-preload files, but is odd. I will look into this next week also.

matz3 commented 7 years ago

@hagen no, I did not have a deeper look into it. Please feel free to do so.

matz3 commented 4 years ago

I'm closing this issue as there wasn't an update since quite a while. Please let me know in case this is still relevant. Please also checkout the UI5 Tooling, which is the successor of the grunt tasks: https://sap.github.io/ui5-tooling/