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.
assets/ directory structure, Twig blocks).nomodule fallbacks, critical for enterprise apps with older browser requirements.webpack-encore-bundle with minimal config changes (e.g., vite_entry_link_tags instead of encore_entry_link_tags). The migration guide provides clear steps.vite-plugin-symfony, which adds a small dependency but enables Symfony-specific features (e.g., asset manifest parsing, Twig integration)..env variables via exposedEnvVars (v8.4.0+), useful for dynamic asset paths or API endpoints.nomodule scripts add ~5–10KB to production builds, impacting performance for modern-only apps.symfony-cli for HTTPS dev server).Frontend Stack Alignment:
Migration Strategy:
Performance Trade-offs:
Dev Experience:
CI/CD Impact:
npm run build replaces Webpack’s yarn encore production.mtdowling/jms-serializer-bundle or api-platform/core for API-driven apps may conflict with Vite’s asset pipeline.Pre-Migration:
assets/, package.json, and webpack.config.js (if using Encore).php.ini if using PHP < 8.0 (not supported).Installation:
composer require pentatrion/vite-bundle
npm install vite vite-plugin-symfony --save-dev
Configuration:
vite.config.js to use named entry points (v1.x format):
export default {
plugins: [symfonyPlugin()],
build: {
rollupOptions: {
input: {
app: "./assets/app.js" // Named entry (no .js extension)
}
}
}
};
config/routes/dev/pentatrion_vite.yaml (auto-generated by recipe).Template Updates: Replace Twig tags:
{% block stylesheets %}
{{ vite_entry_link_tags('app') }} {# Instead of encore_entry_link_tags #}
{% endblock %}
Post-Migration:
npm run dev) and production builds (npm run build).nomodule scripts.npm run build and copy assets to public/build/.AssetMapper for versioned URLs.outDir config in vite.config.js if assets aren’t in public/build/.configs key (see changelog v6.4.3).symfony-cli for HTTPS dev server (see docs).Phase 1: CSS Migration
vite_entry_link_tags for stylesheets.Phase 2: JavaScript Migration
encore_entry_script_tags with vite_entry_script_tags.Phase 3: Framework-Specific
symfony/ux-react).Phase 4: Production Rollout
npm run build and asset caching.vite-plugin-symfony updates are frequent (e.g., Vite 6/7 support in v8.2.0). Teams should monitor the changelog.composer update for bundle changes.controllersDir config (see changelog v8.0.0).outDir is misconfigured).How can I help you explore Laravel packages today?