Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help needed] How do I use this bundle with Symfony's new AssetMapper? #198

Open
MarkDaleman opened this issue May 22, 2024 · 1 comment
Labels
Help wanted Extra attention is needed

Comments

@MarkDaleman
Copy link

MarkDaleman commented May 22, 2024

Hello all 👋,

I'm trying to combine Symfony's new AssetMapper with this library.
As the docs suggests I'm extending the layout-vertical.html.twig template.

In my page.html.twig I have the following:

{% extends '@Tabler/layout-vertical.html.twig' %}

{% block page_content %}
 // yadda yadda 
{% endblock %}

{% block javascripts %}
    {{ parent() }} // So that tabler.js is loaded and we can open/close the mobile menu
    {{ importmap('app') }} // Import our global JS, containing our libraries
    <script type="module">
        import '{{ asset('dashboard.js') }}'; // Import our Dashboard.js on the page.html.twig. I do not want this code to be loaded on every page.
    </script>
{% endblock %}

This kinda works, because I can see the JS is loaded on my page.

If I visit a menu item (for example, the same page) I get the following console errors:

> An import map is added after module script load was triggered.

Also, all the javascript on the page is gone.

Maybe my understanding of AssetMapper isn't good enough or I'm doing something very wrong.

Could you guys point me to the right direction?

@kevinpapst
Copy link
Owner

I doubt its compatible, but the current version of the bundle is based on Webpack Encore.
If you find a solution and share it as PR, I am happy to incorporate it.

@cavasinf cavasinf added the Help wanted Extra attention is needed label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants