Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Vite Bundle

Vite Bundle Laravel Package

pentatrion/vite-bundle

Symfony bundle integrating Vite for easy asset loading. Provides Twig functions to render the right script and link tags for Vite dev server and production builds (including React dependency handling). Install via Composer and use vite_entry_* tags in templates.

View on GitHub
Deep Wiki
Context7

Vite integration for your Symfony app

Frequently asked questions about Vite Bundle
Can I use this bundle with Laravel instead of Symfony? The description mentions Laravel but the package is Symfony-focused.
No, this package is explicitly designed for Symfony and its Twig templating system. Laravel uses Blade templates, so you’d need a custom adapter or a Laravel-specific Vite integration like Laravel Vite Plugin. The bundle leverages Symfony’s routing and Twig blocks, which aren’t directly compatible with Laravel’s architecture.
What Laravel alternatives exist for Vite integration that work with Blade templates?
For Laravel, use the official [Laravel Vite Plugin](https://github.com/laravel/vite-plugin) or packages like `spatie/laravel-vite`. These handle Blade directives (e.g., `@vite`) and Laravel’s asset pipeline. Unlike this Symfony bundle, they don’t require Twig and integrate natively with Laravel’s Mix/Encore replacements.
How do I migrate from Webpack Encore to this bundle in Symfony?
Replace `encore_entry_link_tags` with `vite_entry_link_tags` in your Twig templates and update your `package.json` to use Vite instead of Webpack. Run `npm install` and `npm run dev` to start Vite’s dev server. The bundle provides a [migration guide](https://symfony-vite.pentatrion.com) with step-by-step instructions, including handling Stimulus controllers and React dependencies.
Does this bundle support Laravel’s Mix or Laravel Vite Plugin’s `@vite` directives?
No, this bundle is for Symfony only and uses Twig functions like `vite_entry_link_tags`. Laravel’s Mix or Vite Plugin use Blade directives (e.g., `@vite(['resources/js/app.js'])`). If you’re evaluating Laravel packages, focus on `laravel/vite-plugin` or `spatie/laravel-vite` instead.
Will this bundle work with Symfony 6.4+ and PHP 8.2+?
Yes, the bundle supports Symfony 5.4+ and PHP 8.0+. For Symfony 6.4+, ensure you’re using the latest version (check [Packagist](https://packagist.org/packages/pentatrion/vite-bundle)). PHP 8.2+ is fully compatible, but test your Vite plugins (e.g., `vite-plugin-symfony`) for any breaking changes, as they may depend on Node.js/npm updates.
How do I handle React dependencies in production? The README mentions a `dependency` option.
Use the `dependency` option in `vite_entry_script_tags` to specify React (or other frameworks) for proper chunk splitting and preloading. Example: `{{ vite_entry_script_tags('app', { dependency: 'react' }) }}`. In production, Vite generates a manifest file (`/build/asset-manifest.json`) that the bundle uses to render optimized `<script>` tags with correct `defer` or `async` attributes.
Can I use this bundle without Symfony UX (Stimulus) or React?
Yes, the bundle works for vanilla JavaScript, CSS, or any frontend framework. Stimulus-specific features (like HMR for controllers) are optional. If you’re not using Stimulus, focus on the core Twig functions (`vite_entry_link_tags`, `vite_entry_script_tags`). However, Stimulus integration provides HMR and controller registration out of the box, which simplifies development.
What’s the impact on production build size compared to Webpack Encore?
Vite typically produces smaller production bundles than Webpack Encore due to its native ES modules and optimized dependency handling. However, legacy browser support (polyfills/nomodule) adds ~5–10KB. Test your build with `npm run build` and compare output sizes in `/public/build/`. For modern apps, Vite’s output is often 20–30% smaller than Webpack’s.
How do I configure Vite plugins (e.g., for images or SVGs) with this bundle?
Add plugins to your `vite.config.js` as usual. The bundle doesn’t restrict plugin usage, but ensure plugins are compatible with Vite 4–7. For Symfony-specific plugins (e.g., `vite-plugin-symfony`), they’re included by default. Test plugins in development (`npm run dev`) and verify production builds (`npm run build`) to confirm they work with the bundle’s asset manifest generation.
Does this bundle support Laravel’s asset versioning (e.g., `?id=123`) for cache busting?
No, this bundle is for Symfony and uses Vite’s native asset manifest for cache busting. Symfony’s asset system (e.g., `{{ asset('build/app.js') }}`) isn’t directly compatible. Vite handles versioning via content hashes in filenames (e.g., `app.abc123.js`). If you need Laravel-style versioning, consider using a Laravel-specific Vite package instead.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime