Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Css & Js is not working after run php artisan jetstrap:swap livewire command in laravel version 9 #96

Open
jenishprajapati-easternts opened this issue Dec 29, 2022 · 2 comments

Comments

@jenishprajapati-easternts

Css & Js is not working after run php artisan jetstrap:swap livewire command in laravel version 9

@jenishprajapati-easternts
Copy link
Author

image

@Tiththa
Copy link

Tiththa commented Jan 1, 2023

I resolved it by including the scss files generated by jetstrap.

I had already installed jetstrap with bundles swapped resulting this error occurence

vite.config.js

import { defineConfig } from 'vite';
import laravel, { refreshPaths } from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
+              'resources/sass/app.scss',
                'resources/js/app.js',
            ],
            refresh: [
                ...refreshPaths,
                'app/Http/Livewire/**',
            ],
        }),
    ],
});

Install sass with
npm install --save dev sass

reources/sass/app.scss : change directory path of bootstrap

-  @import '~bootstrap/scss/bootstrap';
+  @import 'node_modules/bootstrap/scss/bootstrap';  

Change your mix styles and scripts with the vite() laravel reference in app layout and guest layout: Optionalin welcome.blade.php if you are going to use it.

Remove both app.js script and app.css and stylesheet, replace with vite syntax

-    <link rel="stylesheet" href="{{ asset('css/app.css') }}">
-    <script src="{{ mix('js/app.js') }}" defer></script>
+    @vite(['resources/sass/app.scss', 'resources/js/app.js'])

Re build and compile assests for build

npm run build
npm run dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants