<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zahidul Islam</title>
    <description>The latest articles on DEV Community by Zahidul Islam (@zahidul1994).</description>
    <link>https://dev.to/zahidul1994</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F907598%2F9d151663-9ddb-4019-9ddf-aab09dbfdb46.jpeg</url>
      <title>DEV Community: Zahidul Islam</title>
      <link>https://dev.to/zahidul1994</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zahidul1994"/>
    <language>en</language>
    <item>
      <title>How to Install Laravel UI Package with Laravel Vite at laravel 9</title>
      <dc:creator>Zahidul Islam</dc:creator>
      <pubDate>Wed, 24 Aug 2022 16:50:33 +0000</pubDate>
      <link>https://dev.to/zahidul1994/how-to-install-laravel-ui-package-with-laravel-vite-at-laravel-9-3bf5</link>
      <guid>https://dev.to/zahidul1994/how-to-install-laravel-ui-package-with-laravel-vite-at-laravel-9-3bf5</guid>
      <description>&lt;p&gt;For some time, many people including me have been facing problems installing Laravel's UI package due to the update of Vite from webpack to Laravel 9.19. I myself faced this problem and solved it after a long time, so many brothers were telling me how I am doing in this inbox, I would like to help them, so I thought to highlight this problem through a small post.&lt;/p&gt;

&lt;h2&gt;
  
  
  this post first publish on &lt;a href="https://www.sohibd.com/info/how-to-install-laravel-ui-package-with-laravel-vite-at-laravel-9"&gt;Install Laravel UI Package with Laravel Vite&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In fact Laravel 9.19 has changed from Laravel Webpack to Viet. In fact, it makes developing Wave applications many times faster than before. So let's start knowing how to install Laravel UI package with Laravel Vite (How to install Laravel UI package with Laravel Vite)&lt;/p&gt;

&lt;p&gt;Step 1:&lt;/p&gt;

&lt;p&gt;Step 2: Install Laravel UI package for Bootstrap &lt;/p&gt;

&lt;p&gt;composer require laravel/ui &lt;/p&gt;

&lt;p&gt;Step 3: Setup Auth Scaffolding with Bootstrap  &lt;/p&gt;

&lt;p&gt;php artisan ui bootstrap –auth &lt;/p&gt;

&lt;p&gt;Step 4: NPM Install &lt;/p&gt;

&lt;p&gt;npm install&lt;/p&gt;

&lt;p&gt;Step 5: Edit Vite.config.js  &lt;/p&gt;

&lt;p&gt;Paste this code &amp;amp; then remove resources/css/app.css &lt;/p&gt;

&lt;p&gt;import { defineConfig } from 'vite'; &lt;/p&gt;

&lt;p&gt;import laravel from 'laravel-vite-plugin'; &lt;/p&gt;

&lt;p&gt;import path from 'path' &lt;/p&gt;

&lt;p&gt;export default defineConfig({ &lt;/p&gt;

&lt;p&gt;plugins: [ &lt;/p&gt;

&lt;p&gt;laravel([ &lt;/p&gt;

&lt;p&gt;'resources/js/app.js', &lt;/p&gt;

&lt;p&gt;]), &lt;/p&gt;

&lt;p&gt;], &lt;/p&gt;

&lt;p&gt;resolve: { &lt;/p&gt;

&lt;p&gt;alias: { &lt;/p&gt;

&lt;p&gt;'~bootstrap': path.resolve(__dirname,  &lt;/p&gt;

&lt;p&gt;'node_modules/bootstrap'), &lt;/p&gt;

&lt;p&gt;} &lt;/p&gt;

&lt;p&gt;}, &lt;/p&gt;

&lt;p&gt;}); &lt;/p&gt;

&lt;p&gt;Step 6: Update Bootstrap .js &lt;/p&gt;

&lt;p&gt;Open resources/js/bootstrap.js then select all code then remove them. Then add  this code: &lt;/p&gt;

&lt;p&gt;import loadash from 'lodash' &lt;/p&gt;

&lt;p&gt;window._ = loadash &lt;/p&gt;

&lt;p&gt;/** &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We'll load the axios HTTP library which allows us to  easily issue requests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;to our Laravel back-end. This library automatically  handles sending the &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;CSRF token as a header based on the value of the  "XSRF" token cookie. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*/ &lt;/p&gt;

&lt;p&gt;import axios from 'axios' &lt;/p&gt;

&lt;p&gt;window.axios = axios &lt;/p&gt;

&lt;p&gt;window.axios.defaults.headers.common['X-Requested-With']  = 'XMLHttpRequest'; &lt;/p&gt;

&lt;p&gt;/** &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Echo exposes an expressive API for subscribing to  channels and listening &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;for events that are broadcast by Laravel. Echo and  event broadcasting &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;allows your team to easily build robust real-time web  applications. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*/ &lt;/p&gt;

&lt;p&gt;// import Echo from 'laravel-echo'; &lt;/p&gt;

&lt;p&gt;// window.Pusher = require('pusher- js'); &lt;/p&gt;

&lt;p&gt;// window.Echo = new Echo({ &lt;/p&gt;

&lt;p&gt;// broadcaster: 'pusher', &lt;/p&gt;

&lt;p&gt;// key: process.env.MIX_PUSHER_APP_KEY, // cluster: process.env.MIX_PUSHER_APP_CLUSTER, // forceTLS: true &lt;/p&gt;

&lt;p&gt;// });&lt;/p&gt;

&lt;p&gt;Step 7: Import Bootstrap SCSS in JS folder &lt;/p&gt;

&lt;p&gt;Open resources/js/app.js then select all code then remove them. Then add this  code: &lt;/p&gt;

&lt;p&gt;import './bootstrap'; &lt;/p&gt;

&lt;p&gt;import '../sass/app. scss' &lt;/p&gt;

&lt;p&gt;import * as bootstrap from 'bootstrap' &lt;/p&gt;

&lt;p&gt;Step 8: Replace Webpack mix() with @blade Directive &lt;/p&gt;

&lt;p&gt;Usually when we install Laravel fresh project it run it’s css and js with webpack. But  when we use Laravel @vite, we need to replace Laravel mix() with @blade. &lt;/p&gt;

&lt;p&gt;Open views/layouts/app.blade.php &lt;/p&gt;

&lt;p&gt;Here you can see two link: &lt;/p&gt;

&lt;p&gt;One for js file and another for css file. It is usable with Laravel mix() but it can not  work with Laravel @vite. Now remove both css and js link. &lt;/p&gt;

&lt;p&gt;for more any issue ar need help please  &lt;a href="%5Bcontact%5D(https://www.sohibd.com/contact-us)&amp;lt;br&amp;gt;%0Ax"&gt;Contact&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>sohibd</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
