@Armani First make sure you installed the sass dependency, run npm add --save-dev sass in the root of your project.
Next, suppose your vite.config.js file looks like this:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
laravel({
// input: 'resources/js/app.js',
input: [
'resources/scss/ltr.scss',
'resources/scss/rtl.scss',
'resources/js/app.js',
],
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
});
Suppose your resources/scss/rtl.scss file looks like this:
body {
direction: rtl;
}
Then in your app.blade.php file you could do something like this:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full bg-gray-200">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title inertia>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Scripts -->
@routes
@vite('resources/js/app.js')
<!-- This logic will be specific to your app, modify this to fit your needs -->
@if(app()->isLocale('ar'))
@vite('resources/scss/rtl.scss')
@else
@vite('resources/scss/ltr.scss')
@endif
@inertiaHead
</head>
<body class="h-full font-sans antialiased">
@inertia
</body>
</html>