Okay, I've decided to be my own hero:
Unlike what AI overlord said above, you can use Laravel 10 + Vite + Sass setup, here's what you need to do:
Laravel does not come with lodash preinstalled, so if you want to use Sass don't forget to
npm install lodash
Based on a simplified project structure:
laravel-app/
├─ resources/
│ ├─ css/
│ │ ├─ global/
│ │ │ ├─ _index.scss
│ │ │ ├─ _layout.scss
│ │ │ ├─ _reset.scss
│ │ │ ├─ _variables.scss
│ │ ├─ app.scss
│ ├─ views/
│ │ ├─ layout.blade.php
vite.config.js
1.vite.config.js
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.scss', 'resources/js/app.js'],
refresh: true,
}),
],
});
2.layout.blade.php (basically, file with header and footer data that will be loaded on every page of your app)
<head>
@vite(['resources/css/app.scss', 'resources/js/app.js'])
</head>
3.Sass files (from here on you can just follow Sass documentation)
3.1._index.scss
@forward 'variables';
@forward 'reset';
@forward 'layout';
3.2._layout.scss (and other files)
@use 'variables' as *;
3.3.app.scss
@use 'global' as *;
However, to me personally it still remains unclear as to whether it's better to just use Vanilla CSS + PostCSS in Laravel 10 projects or not.