The Laravel 9 + Bootstrap Template is a modified version of the laravel/laravel package. It includes several changes such as the removal of PostCSS, the installation of SASS and Bootstrap, and the restructuring of resource folders. The template also includes modifications to the vite.config.js file to include the new resource files in the compilation process. In addition, changes have been made to the welcome view, including the inclusion of assets using the @vite directive and the modification of content.
To reproduce this template, follow these steps:
Modify the package.json file:
Remove PostCSS by running the command:
npm remove postcss
Install all NPM packages (including updated versions of vite and laravel-vite-plugin) by running the command:
npm i
Install SASS by running the command:
npm i --save-dev sass
Rename the “css” folder in the “resources/” directory to “scss”.
Rename the “app.css” file in the new “resources/scss” directory to “app.scss”.
Modify the vite.config.js file:
alias: {
...
'~resources': path.resolve(__dirname, 'resources'),
}
Add the line “import ‘~resources/scss/app.scss’;” in the resources/js/app.js file to import the main SCSS file using JavaScript.
Add the “@vite(‘resources/js/app.js’)” directive in the section of the resources/views/welcome.blade.php file to include the assets in the view.
Add the following lines in the resources/js/app.js file to instruct Vite and Blade to process the assets correctly:
import '@vitejs/plugin-legacy';
import '@vitejs/plugin-views';
Add the line “package-lock.json” in the .gitignore file located in the root of the project to avoid publishing it to the repository.
Install Bootstrap by running the command:
npm i --save bootstrap @popperjs/core
Add the line “const path = require(‘path’);” in the vite.config.js file before the line “export default defineConfig({”.
Add the line “’~bootstrap’: path.resolve(__dirname, ’node_modules/bootstrap’),” in the resolve.alias object in the vite.config.js file.
Add the line “@import “~bootstrap/scss/bootstrap”;” at the top of the resources/scss/app.scss file to import the CSS part of Bootstrap.
Add the line “import * as bootstrap from ‘bootstrap’;” in the resources/js/app.js file to import the JS part of Bootstrap.
The Laravel 9 + Bootstrap Template is a customized version of the laravel/laravel package that includes the installation of SASS and Bootstrap, removal of PostCSS, and restructuring of resource folders. Additionally, modifications are made to the compilation process and the welcome view. By following the provided installation guide, users can reproduce this template in their Laravel projects.