Lädt...


🔧 Laravel Mix vs Vite: Why did Laravel Transitioned to Vite


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Asset bundling is a core part of modern web development, helping optimize and manage CSS, JavaScript, and other resources. For years, Laravel Mix streamlined this process, but as JavaScript tools evolved, Laravel has transitioned to Vite as the default in Laravel 11.

So why has Laravel made this switch?

speed

Performance and Speed

Vite focuses on two main things: development speed and production performance. If you’re tired of waiting around for builds, Vite’s instant feedback will feel like a breath of fresh air. With Hot Module Replacement (HMR), Vite’s development server delivers changes in real time, so you can see updates instantly, without a full page refresh. This immediate feedback creates a faster, more enjoyable development experience.

bundle based
Laravel Mix uses this approach, and it requires significant initial bundling time, resulting in a delay before the server is ready.

esm-based
This ESM-based approach is much faster in development, as it avoids the full bundling process. Vite uses this approach, allowing developers to see changes instantly without waiting for a full bundle.

(the pictures are from Vite's official documentation)

For production builds, Vite uses Rollup as its bundler, optimizing and minifying your code to ensure fast performance. This allows Vite to offer the best of both worlds: no-bundle development for speed during coding and traditional bundling for optimized production builds.

modern

Modern Javascript Support

Vite also excels at tree shaking and code splitting. By leveraging Rollup, Vite produces optimized production bundles, stripping out unused code and splitting assets as needed. This results in smaller, faster-loading bundles that enhance your app’s performance.

Enhanced Developer Experience

Vite’s configuration process is refreshingly straightforward. Unlike Webpack, where configurations can become dense and complex, Vite’s vite.config.js file is easy to read and customize, even if you don’t have extensive bundler experience.

Plus, Vite is built to work seamlessly with popular frameworks like Vue and React. Since these frameworks also benefit from Vite’s HMR and optimized development environment, you can work more efficiently on front-end-heavy Laravel projects.

community

Future-Proofing and Community Adoption

The JavaScript ecosystem is evolving fast, and Vite has gained a solid foothold. It’s widely adopted and supported, with a large, active community that brings ongoing improvements and a rich resource of plugins. Vite’s design aligns well with where front-end development is headed, making it a smart choice if you want to future-proof your project.

Laravel’s decision to adopt Vite shows a clear alignment with modern standards, positioning your Laravel projects to stay compatible with the latest front-end technologies.

Laravel Integration

Laravel’s Vite Plugin includes handy helper functions like @vite for Blade templates, automatically handling asset versioning and cache busting. With just @vite('resources/css/app.css'), you can link your CSS file without worrying about stale cache issues.

Here’s how you can set up vite.config.js for a Laravel + Vue project:

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [vue()],
});

And then in the blade:

<!DOCTYPE html>
<html>
<head>
    @vite('resources/css/app.css')
</head>
<body>
    <h1>Hello, Vite!</h1>
</body>
</html>

And with Laravel’s official support and documentation now focused on Vite, you’ll find consistent guidance and resources to help you get the most out of this tool.

In summary, Vite brings the speed, simplicity, and future-ready features that modern Laravel projects need. By making Vite the default in Laravel 11, Laravel is empowering developers to build faster, leaner, and more efficient applications, especially as JavaScript and web development standards continue to evolve. Dive into Laravel’s official documentation for more insights and get started with Vite today!

...

🔧 Laravel Mix vs Vite: Why did Laravel Transitioned to Vite


📈 91.35 Punkte
🔧 Programmierung

🐧 For newbies: how and why I transitioned to Linux--how you can, too (by Wikipedia's co-founder)


📈 32.01 Punkte
🐧 Linux Tipps

🐧 For newbies: how and why I transitioned to Linux--how you can, too (by Wikipedia's co-founder)


📈 32.01 Punkte
🐧 Linux Tipps

🔧 Why Vite is the best? Advanced Features of Vite


📈 27.49 Punkte
🔧 Programmierung

🍏 Starlink Residential: Transitioned To It, Dumping Comcast Business Internet


📈 27.43 Punkte
🍏 iOS / Mac OS

📰 Rewiring My Career: How I Transitioned from Electrical Engineering to Data Engineering


📈 27.43 Punkte
🔧 AI Nachrichten

📰 Rewiring My Career: How I Transitioned from Electrical Engineering to Data Engineering


📈 27.43 Punkte
🔧 AI Nachrichten

📰 How I Transitioned From Analyst to Data Scientist In Less Than 12 Months


📈 27.43 Punkte
🔧 AI Nachrichten

📰 How I Transitioned From Analyst to Data Scientist In Less Than 12 Months


📈 27.43 Punkte
🔧 AI Nachrichten

📰 Demand For Employee Surveillance Increased As Workers Transitioned To Home Working


📈 27.43 Punkte
📰 IT Security Nachrichten

🐧 Did and why did RPM distros have more problems with dependency hell?


📈 23.92 Punkte
🐧 Linux Tipps

🔧 [Laravel v11 x Docker] Efficiently Set Up a Laravel App Dev Environment with Laravel Sail


📈 23.54 Punkte
🔧 Programmierung

🔧 Make Your Vite Project LLM-Friendly with vite-plugin-llms


📈 22.9 Punkte
🔧 Programmierung

📰 Webentwicklung: Build-Tool Vite.js 5.1 experimentiert mit Vite Runtime API


📈 22.9 Punkte
📰 IT Nachrichten

🔧 Webentwicklung: Build-Tool Vite.js 5.1 experimentiert mit Vite Runtime API


📈 22.9 Punkte
🔧 Programmierung

📰 Xiaomi Mix Fold 4, Mix Flip und mehr werden am 19. Juli 2024 vorgestellt


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi Mix Fold 4 und Mix Flip erscheinen noch im Juli 2024


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi-Chef spricht von Mix Fold 4 und Mix Flip


📈 22.17 Punkte
🤖 Android Tipps

📰 Xiaomi Mi Mix 4, Mi Mix Alpha und Co.: So geht es mit der Reihe weiter


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi bringt erst mal nichts Neues für Mix-Serie, lässt Mi Mix Alpha fallen


📈 22.17 Punkte
📰 IT Nachrichten

🪟 Microsoft's AI journalists mix up multiracial Little Mix singers


📈 22.17 Punkte
🪟 Windows Tipps

📰 Xiaomi Mi Mix 4: Wo bleibt der Mix-3-Nachfolger?


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi Mi MIX Alpha aka MIX 4: 108-Mepapixel-Sensor bestätigt


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi Mi MIX 2S und Mi 8 erhalten Kamera-Nachtmodus von Mi MIX 3


📈 22.17 Punkte
📰 IT Nachrichten

📰 Mi 8 und Mi MIX 2S sollen verbesserte Kamera-Software des Mi MIX 3 erhalten


📈 22.17 Punkte
📰 IT Nachrichten

📰 Smartphone Ulefone Mix im Test: Mi-Mix-Kopie fürs kleine Geld


📈 22.17 Punkte
📰 IT Nachrichten

📰 MIX Fold 4 vs. MIX Flip: So unterscheiden sich die Xiaomi-Handys


📈 22.17 Punkte
📰 IT Nachrichten

📰 Mix Fold 4 und Mix Flip: Die nächste Foldable-Generation von Xiaomi


📈 22.17 Punkte
📰 IT Nachrichten

📰 Mix Fold 4 und Mix Flip: Xiaomi stellt ebenfalls dünne faltbare Smartphones vor


📈 22.17 Punkte
📰 IT Nachrichten

📰 Xiaomi teasert Mix Flip & Mix Fold 4 an: In allen Punkten vor Samsung?


📈 22.17 Punkte
📰 IT Security Nachrichten

🔧 What is Laravel Development and Why Should You Select Laravel for Your Next Project?


📈 20.28 Punkte
🔧 Programmierung

matomo