Call Anytime 24/7
Mail Us For Support
Office Address
Lahore, Punjab, Pakistan
Now Hiring: Are you a driven and motivated 1st Line IT Support Engineer?
Office Hours: 10:00am-6:00pm
Call Anytime 24/7
Mail Us For Support
Office Address
Laravel has become the go-to PHP framework for building modern, scalable web applications. Starting from Laravel 9.19, the framework switched from Laravel Mix (Webpack) to Vite, a lightning-fast build tool designed for modern frontend development.
While Vite makes handling JavaScript, CSS, and images much easier, many developers struggle when it comes to favicon and manifest icons setup in Laravel. These icons are critical because they:
In this guide, we’ll cover everything you need to know about setting up and managing Vite Icon Manifest Icons in Laravel, including installation, configuration, troubleshooting, and best practices.
Before diving into Laravel + Vite, let’s break down what manifest icons are.
A web app manifest is a JSON file (manifest.json) that defines how your web app should behave when installed on a device or added to the home screen. One of its most important parts is the icons array, which provides images in different sizes and formats.
👉 In Laravel with Vite, these icons must be handled carefully so that Vite’s asset pipeline knows where to put them.
Laravel’s move to Vite has many advantages:
When combined with Laravel’s Vite::asset() helper, you can easily link to your icons in Blade templates.
If you already have Vite configured, you can skip this section.
composer create-project laravel/laravel vite-icons-demo
cd vite-icons-demo
npm install
npm run dev
This sets up Vite for asset compilation.
By default, Laravel ships with:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
  plugins: [
    laravel({
      input: ['resources/css/app.css', 'resources/js/app.js'],
      refresh: true,
    }),
  ],
});
Now let’s integrate icons properly.
Create icons in different sizes:
📂 Save them inside resources/images/icons/.
Update vite.config.js to ensure icons are copied into the public/build directory.
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { resolve } from 'path';
export default defineConfig({
  plugins: [
    laravel({
      input: [
        'resources/css/app.css',
        'resources/js/app.js',
        'resources/images/icons/favicon.ico',
        'resources/images/icons/icon-192.png',
        'resources/images/icons/icon-512.png',
      ],
      refresh: true,
    }),
  ],
  build: {
    manifest: true,
    rollupOptions: {
      input: {
        app: resolve(__dirname, 'resources/js/app.js'),
        favicon: resolve(__dirname, 'resources/images/icons/favicon.ico'),
      },
    },
  },
});
This ensures your icons appear in public/build/manifest.json.
Inside resources/views/layouts/app.blade.php, add:
<!-- Favicon -->
<link rel="icon" href="{{ Vite::asset('resources/images/icons/favicon.ico') }}">
<!-- Android PWA Icons -->
<link rel="icon" type="image/png" sizes="192x192" href="{{ Vite::asset('resources/images/icons/icon-192.png') }}">
<link rel="icon" type="image/png" sizes="512x512" href="{{ Vite::asset('resources/images/icons/icon-512.png') }}">
<!-- Apple iOS Icon -->
<link rel="apple-touch-icon" href="{{ Vite::asset('resources/images/icons/icon-192.png') }}">
<!-- Manifest -->
<link rel="manifest" href="/manifest.json">
Inside public/manifest.json:
{
  "name": "My Laravel Vite App",
  "short_name": "LaravelVite",
  "icons": [
    {
      "src": "/build/assets/icon-192.png",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "/build/assets/icon-512.png",
      "sizes": "512x512",
      "type": "image/png"
    }
  ],
  "start_url": "/",
  "display": "standalone",
  "theme_color": "#ffffff",
  "background_color": "#000000"
}
Now, when you run npm run build, Vite will hash and map your icons in manifest.json.
Even experienced developers face hiccups. Let’s troubleshoot:
✅ Check public/build/manifest.json for correct paths.
✅ Clear browser cache and run:
php artisan view:clear
php artisan cache"clear
npm run build
✅ Use Vite::asset() instead of hardcoding paths.
✅ Add <link rel=”apple-touch-icon”> manually in Blade.
Instead of manual setup, use:
npm install vite-plugin-pwa --save-dev
vite.config.js:
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
  plugins: [
    laravel(...),
    VitePWA({
      registerType: 'autoUpdate',
      manifest: {
        name: "Laravel Vite App",
        short_name: "LaravelVite",
        icons: [
          {
            src: "icon-192.png",
            sizes: "192x192",
            type: "image/png"
          },
          {
            src: "icon-512.png",
            sizes: "512x512",
            type: "image/png"
          }
        ]
      }
    })
  ]
});
{
  "src": "/build/assets/icon-512.png",
  "sizes": "512x512",
  "type": "image/png",
  "purpose": "maskable"
}
Configuring Vite Icon Manifest Icons in Laravel might seem tricky at first, but with the right setup, you’ll:
👉 Whether you’re building a portfolio site, SaaS app, or e-commerce store, adding manifest icons the right way makes your Laravel app look professional, trustworthy, and future-proof.
Use Vite::asset(‘resources/images/icons/favicon.ico’) inside your Blade template.
Place it inside the public/ folder, e.g., public/manifest.json.
No, but it automates the process of generating manifest.json and service workers.
Yes, but browsers often require PNGs for manifest.json icons. SVG is better for inline favicons.
Check public/build/manifest.json, clear caches, and always reference icons with Vite::asset().
AI Marketing AI Tools best developer tools 2025 best IDEs for web developers Content Creation Create GraphSQL Digimax Template Kit Digital Marketing Agency Template Download Elementor Kit Elementor Landing Pages Elementor Pro Design Elementor Pro Template Kit free coding tools Pakistan Free Elementor Templates Free Website Templates Graph database Graph database installation Graph database model Graph data structure Graph relationships GraphSQL GraphSQL query GraphSQL tutorial GraphSQL vs relational databases GraphSQL vs SQL laravel Laravel development tools Laravel Guide Laravel Tutorial llms.txt for AI crawlers llms.txt vs robots.txt Marketing Neo4j GraphSQL paid web development software PHP Framework RomoAI SEO Agency Template Top 20 Digital Marketing AI Tools in 2025 top web design tools Pakistan Web Development web development tools in Pakistan Website Security Website Speed Optimization WordPress WordPress Design Kit


Comments are closed