Include local third party JS script to template

Viewed 230

I have a Shopware 6 plugin and I want to add a third party JS file that should be located in my plugin to the template like this:

{% sw_extends '@Storefront/storefront/base.html.twig' %}

{% block base_body_script %}
    <script src="myscript.js"></script>
    {{ parent() }}
{% endblock %}

The file is supposed to exist in my plugin, because there is no official URL to that file, I have downloaded it from github. I have not found any information about where exactly in my plugin I need to put the file and then what exactly the path to the file is.

It's a plain JS file with variable assignments and functions. There is no export or something like this.

My initial problem was that I want to use some variables from this file in my JS Plugin. But I can't put that file next to my JS Plugin and just import it with import './myscript.js';, because it has no "export" and thus I can't access the variables. So my approach is to include the file in template, but now I have the problem described above.

0 Answers
Related