Closed ckanitz closed 2 weeks ago
hi @ckanitz ,
I think you forgot to add react
as dependency in your twig function documentation
{% block javascripts %}
{{ vite_entry_script_tags('app', { dependency: 'react'}) }}
{% endblock %}
hi @ckanitz , I think you forgot to add
react
as dependency in your twig function documentation{% block javascripts %} {{ vite_entry_script_tags('app', { dependency: 'react'}) }} {% endblock %}
I feakin' love you man <3 BANZAI!
https://github.com/lhapaipai/symfony-vite-dev/issues/30#issuecomment-2176052400 resolved the issue, thx again
vite-plugin-symfony version
6.4.7
vite-bundle version
6.4.7
your OS, node version, Symfony version, PHP version
MacOS 14, node 20.11.0, Symfony 6.4.x
Description
I've got the extended version of the Mantis Dashboard (https://github.com/codedthemes/mantis-free-react-admin-template) which uses vite. I followed the migration guide to replace webpack with vite. My build-pipeline + dev-serv stack works fine on
npm start
:"scripts": { "start": "composer install && npm install && npm run build && npm run serve", "build": "vite build", "dev": "vite", "serve": "docker-compose up -d && symfony serve -d", "stop": "docker-compose stop && symfony local:serve:stop", ... },
But on
npm run dev
(afternpm start
) I'll get the following error in my console:Uncaught Error: @vitejs/plugin-react can't detect preamble on Mantis-Dashboard
also pointing to a (3 year old & closed) GitHub discussion: https://github.com/vitejs/vite-plugin-react/issues/11#discussion_r430879201How to reproduce
Setup a symfony project.
Setup vite.
Grab the free mantis dashboard project https://github.com/codedthemes/mantis-free-react-admin-template
Create a
script.js
in the<symf>/assets/
folder (will be used for everything unrelated to the dashboard, like analytics)Create a folder
<symf>/src-dashboard
Copy the contents of
<mantis>/src
to<symf>/src-dashboard
Add (dev)dependencies needed by mantis to symfony project
Adjust the
<symf>/vite.config.mjs
:Copy
jsconfig.json
and adjustsrc
tosrc-dashboard
For completion, my index.html.twig looks like this:
Possible Solution
No response