What happens if you re-run it? and what's the content of compiled files?
Jul 2, 2022
6
Level 2
Laravel Vite and SASS
Update - Working files
Since this post has gotten traction and the original was not clear, I've updated it to help people who find this on Google.
Steps to make SASS work with your project
- Run the following command:
npm add -D sass - Add the path to your SASS file in the
input:
vite.config.js
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
export default defineConfig({
plugins: [
laravel({
input: ["resources/sass/app.scss", "resources/js/app.js"], // add scss file
refresh: true,
}),
],
});
- Then finally add the following line in your blade file:
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
Sass should now be working withing your project.
Level 1
Your config file is OK.
Export from SCSS to CSS use the "npm run build" command, a file will be created in the public/build folder. www.laravel-vite.dev/guide/essentials/building-for-production.html
My vite.config.js:
import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin';
export default defineConfig({ plugins: [ laravel([ 'resources/css/app.scss', // scss file 'resources/js/app.js', ]), ], });
Laravel Blade:
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Scripts -->
@vite(['resources/scss/app.scss', 'resources/js/app.js'])
</head>
...
Good luck :D
9 likes
Please or to participate in this conversation.