Closed Rom1-B closed 3 weeks ago
ping @cconard96
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.
Adding ..
before /public
seems to work in my case:
EDIT : It doesn't work everywhere
Adding
..
before/public
seems to work in my case: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.
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.
Fixed in #17537.
Code of Conduct
Is there an existing issue for this?
Version
11
Bug description
On my development workstation, I have several instances of GLPI installed in subfolders. For GLPI MAIN, the URL is
http://localhost/GLPI/main
, the page is displayed, but it can't find thevue.js
elements, as it tries to openhttp://localhost/public/build/vue//vue-sfc/FuzzySearch-Modal-vue.js
Relevant log output
No response
Page URL
No response
Steps To reproduce
No response
Your GLPI setup information
GLPI information
Server
GLPI constants
Libraries
LDAP directories
SQL replicas
Notifications
Plugins list
Anything else?
No response