Code Monkey home page Code Monkey logo

Comments (5)

Rom1-B avatar Rom1-B commented on July 28, 2024

ping @cconard96

from glpi.

cedric-anne avatar cedric-anne commented on July 28, 2024

As far as I remember, in the .webpack.config.js, we had to use the following configuration to keep URLs relatives: publicPath: ''. I guess the same hack should be used for vue components.

from glpi.

Rom1-B avatar Rom1-B commented on July 28, 2024

Adding .. before /public seems to work in my case:

image

EDIT : It doesn't work everywhere

from glpi.

cedric-anne avatar cedric-anne commented on July 28, 2024

Adding .. before /public seems to work in my case:

image

EDIT : It doesn't work everywhere

Indeed, it work only if the current path has a precise count of directories (e.g. it could work for /front/central.php but not for /front/asset/assetdefinition.php).

I tried to use a direct import instead of using the import.meta.webpackContext(), because I was not able to find any documentation explaining how we could adapt the URL resolution (I am not sure it is even possible).
Here is the patch:

diff --git a/js/src/vue/app.js b/js/src/vue/app.js
index 6cadc3c5b9..c074724a08 100644
--- a/js/src/vue/app.js
+++ b/js/src/vue/app.js
@@ -72,8 +72,11 @@ const components = {};
 component_context.keys().forEach((f) => {
     // Ex: ./Debug/Toolbar.vue => DebugToolbar
     const component_name = f.replace(/^\.\/(.+)\.vue$/, '$1');
+    const path = CFG_GLPI.root_doc + '/public/build/vue/vue-sfc/' + component_name.replace('/', '-') + '-vue.js';
     components[component_name] = {
-        component: vue.defineAsyncComponent(() => component_context(f)),
+        component: vue.defineAsyncComponent(
+            () => import(/* webpackIgnore: true */path)
+        ),
     };
 });
 // Save components in global scope

The /public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js file is loaded, but nothing happens (the fuzzy search does not works).

I also tried to use an importmap, but it does not works. Either I made a mistake, either webpack does not use imports and it then does not work.

    <script type="importmap">
        {
            "imports": {
                "/public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js": "{{ config('root_doc') }}/public/build/vue/vue-sfc/FuzzySearch-Modal-vue.js"
            }
        }
    </script>

Another solution could be to use a <base href="{{ config('root_doc') }}"> tag in our pages <head>, but may have unexpected side effects. I did not tried this solution.

@cconard96 Could you take a look on it? It is really important as it make GLPI unusable when it is not located at the web server root path, for instance when the path is defined by an Alias apache directive.

from glpi.

cconard96 avatar cconard96 commented on July 28, 2024

Using <base> isn't a real option. It will break anchors since we use #anchor, it would refer to the base URL and not the current page anymore.

from glpi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.