Joomla add 3rd party component

146 views Asked by At

I'm trying to include a svelte app to Joomla site by copy all files from public to Joomla local folder, and in Joomla, I've created an article with a script where I include this index.html

Svelte output

+---public
|   |   favicon.png
|   |   index.html
|   |   output.doc
|   |   
|   \---build
|           bundle.css
|           bundle.css.map
|           bundle.js
|           bundle.js.map

Joomla script to include index.html

{source}

<?php ini_set("include_path", "/var/www/vhosts/examplesite.com/httpdocs/files/forms/public"); ?>

<?php include 'index.html'; ?>

{/source}

Locally when I launch index.html from the public, all works fine, bun in Joomla noop. The error is that Joomla can't find files from build folder, for example in index.html are included bundle.css like this:

<script defer src='./build/bundle.js'></script>

And I expected what full path for bundle.js will be:

https://www.examplesite.com/files/forms/public/bundle.js

but actually, the browser requires it from

https://www.examplesite.com/bundle.js

So, there is a problem with the path for all files from the build folder. Help !!!

1

There are 1 answers

1
Stephane Vanraes On

if you do

<script defer src='./build/bundle.js'</script>

the browser will indeed try to get it from the location you mentioned, this is because the ./ part indicates the root and makes it an absolute path.

Change your markup to:

<script defer src='/build/bundle.js'</script>

to have it search the bundle files relatively to the current location.