简体   繁体   中英

Joomla add 3rd party component

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 !!!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM