Styling — Dark Theme
Website Rebuild with Laravel
Chapter 5 · Styling — Dark Theme
Django Rebuild 5 had no bundler at all — staticfiles just serves plain files, exactly as written. Next.js bundles CSS as an inseparable part of the framework's own build system. Laravel lands on neither extreme: composer create-project already installed and pre-configured a real, independent tool — Vite — without folding bundling into Laravel itself. A genuine third position, not a compromise between the other two.
The @vite Directive
Django's own {% static %} tag points at a plain, unprocessed file — served exactly as it sits on disk. @vite points at a source file that genuinely gets processed — Sass, PostCSS, autoprefixing, and (in development) live hot-reloading are all real, available capabilities the moment they're needed, not something bolted on afterward.
vite.config.js: Already Generated, Nothing to Set Up
staticfiles genuinely has no bundling concept. Laravel does neither: it hands you a real, independently-maintained tool, already wired up and ready, but never claims to be that tool itself. vite.config.js existing as its own real, separate file — not hidden inside Laravel's own internals — is the visible proof of that distinction.
A Real Gotcha: Two Processes Running at Once, in Development
@vite doesn't read a static file at all — it connects to a running Vite dev server on its own port, expecting a live process to actually answer. Forget to start npm run dev, and there's nothing there to connect to: the page can show a connection error, or fail to load any asset at all, not just a missing stylesheet. This is a genuinely different failure shape from Django Rebuild 5's own DEBUG=False gotcha — Django's problem only appears in production, once a specific setting flips; Laravel's version can happen on literally the very first day of local development, the moment one of two required processes isn't running.
Production: npm run build and the Manifest
This is Laravel's own direct parallel to Django Rebuild 11's forward-referenced collectstatic step — a real, necessary build action that has to happen as part of deployment, not something to discover was missing after the site is already live.
The Stylesheet: The Same Palette, a Third Time
The same background, surface, border, and text colors from Chapter 5 of both sibling courses, reused here for the third and final time in this "same site, three frameworks" trilogy — deliberate continuity, not repetition for its own sake. A visitor moving between any of the three shouldn't be able to tell which one they're looking at.
Hands-On Exercises
Explain the genuine three-way difference in asset bundling between Next.js, Django, and Laravel. Is Laravel "a bundler" the same way Next.js is? Why or why not?
📄 View solutionExplain why forgetting to run npm run dev alongside php artisan serve breaks the page's assets, and how this failure differs in timing from Django's own DEBUG=False static-file gotcha.
Explain what changes about how @vite resolves its assets between development (with npm run dev running) and production (after npm run build has already executed).
Chapter 5 Quick Reference
- A genuine third position — Next.js bundles by framework design, Django has no bundler at all, Laravel ships a real separate tool (Vite) pre-wired, without being one itself
@vite([...])— points at real source files, genuinely processed, unlike Django's{% static %}serving plain files as-isvite.config.js— already generated bycomposer create-project, nothing to set up manually- Two processes in development —
php artisan serveandnpm run devboth required; forgetting the second breaks the page immediately, not just in production npm run build— generates the production manifest@vitereads instead of a dev server; Laravel's own parallel to Django'scollectstatic- The same palette, a third time — deliberate visual continuity across all three rebuild courses and the live site itself
- Next chapter: The Database: Eloquent ORM