lhapaipai / vite-bundle

Integration with your Symfony app & Vite

Home Page:https://symfony-vite.pentatrion.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Help]: "Unknown "vite_entry_link_tags" function."

sven-ahrens opened this issue · comments

commented

Hey,

Intro

I wanted to replace the old webpack stuff with this vite package and have been following the migration guide for that. Now, I'm using a docker setup with Symfony where I want to inlcude the vite scripts.

{% block stylesheets %}
            {{ vite_entry_link_tags('app') }}
        {% endblock %}

        {% block javascripts %}
            {{ vite_entry_script_tags('app') }}

            {# if you are using React, you have to replace with this #}
            {{ vite_entry_script_tags('app', { dependency: 'react' }) }}
        {% endblock %}

Problem

Now, when I run my docker setup and running the vite server via npm run dev I get the following error message:

Bildschirmfoto 2024-01-23 um 12 57 29

Context

Im not using the default symfony serve but docker and nginx instead, but this shouldn't be a problem in my opinion

Composer

  • "pentatrion/vite-bundle": "^6.3"
  • Symfony 7.x

NPM

  • "vite": "^5.0"
  • "vite-plugin-symfony": "^6.3.2"

My Vite Config

import { defineConfig } from 'vite';
import symfonyPlugin from "vite-plugin-symfony";

export default defineConfig({
  plugins: [
    symfonyPlugin(),
  ],
  build: {
    rollupOptions: {
      app: './assets/js/app.js',
      input: {
        app: './assets/js/app.js',
        theme: './assets/css/app.scss',
      },
    },
  },
});

Hi @sven-ahrens, vite_entry_link_tags is a twig function registered with pentatrion/vite-bundle.
Is the bundle correctly enabled for all the environments ?

// config/bundles.php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
    Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
+    Pentatrion\ViteBundle\PentatrionViteBundle::class => ['all' => true],
];

hi @sven-ahrens, have you tried my solution? otherwise I will close the ticket because it cannot be resolved without further details. do not hesitate to reopen it if you have additional elements to bring