Quick setup the Bootstarp and Laravel 9 in few steps Β π

Software engineer
Search for a command to run...

Software engineer
Thank you Roshan. It really helps me.
"Talk is cheap. Show me the code." β Linus Torvalds β¨ How can you call yourself a good painter if you have not made any painting in life. you canβt be good artist just by reading books or passing comments on other paint works. If you think you are go...
This command is just to give some description about what you did so far, this will help camera to remember even if you check it after a year. It can tell you exactly what, when, who was doing this. Now you have the exact copy of your original work, ...
We just need 3 things to work, React , Formik & YUP (Obviously). π€¦ I will be assuming that you already setup the react and just looking something for the validating the form. React Js: Just incase if you haven't, here is the link to setup the react...

I am going to use the composer to setup everything here.
composer create-project laravel/laravel simple-project-name
This will basically setup the new laravel project in your machine.
Once the setup is complete, cd simple-project-name to move inside your project and
follow below code.
composer require laravel/ui
This add the laravel/ui package inside your project. We will further use this ui package to add the bootstrap.
So far so good , Hopefully you are not facing any issue till now. Moving on,
php artisan ui bootstrap
Before we move on to another steps, make sure you have nodejs setup on your machine.
npm install
and build everything
npm run build
Add the resolve: {} field just below the plugins inside the vite.config.js,
resolve: {
alias: {
"~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
},
},
Make sure to import the path at the top
So now your vite config file should looks something like this:
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import path from "path";
export default defineConfig({
plugins: [
laravel({
input: ["resources/sass/app.scss", "resources/js/app.js"],
refresh: true,
}),
],
resolve: {
alias: {
"~bootstrap": path.resolve(__dirname, "node_modules/bootstrap"),
},
},
});
resource/js folderJust import the resource/scss/app.scss file inside the resource/js/app
so now your app.js file should look like this
import "./bootstrap";
// add this like
import "../sass/app.scss";
@vite(['resources/js/app.js'])
My app.blade.php looks like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Article App</title>
// New like added here
@vite(['resources/js/app.js'])
</head>
Everything is now done, just make sure the restart the server by doing
php artisan serve
And rebuild the npm package by
npm run build
Or or or, just use the CDN if you want to quickly start.
Byeeeeeeeee π»
