Coder Social home page Coder Social logo

vite-livewire-plugin's People

Contributors

ariaieboy avatar balotias avatar dependabot[bot] avatar fabio-ivona avatar marispro avatar trippo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vite-livewire-plugin's Issues

Double check with Livewire v3

I'm kind of certain that a full refresh is taking place in Livewire v3 right now!

Can someone double check it, please?

If it works, can you share your entire setup for a fresh laravel installation?

TypeError when starting Vite

Hello Team defstudio,

first, I would like to say thank you for this great plugin! ๐Ÿ†

When I follow the installation steps for the plugin, I get this error message back:

failed to load config from /Users/BOB/Dev/PHP/Laravel/PROJECT/vite.config.js
error when starting dev server:
TypeError: livewire is not a function
    at file:///Users/BOB/Dev/PHP/Laravel/PROJECT/vite.config.js.timestamp-1683899540373-e3c526847558a.mjs:14:5
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

I have another (older) Laravel project that works just fine with the given instructions. I noticed that package.json now is of type=module and that the postcss.config is now export default { instead of module.exports = {, but I do not know if that is the reason.

My current vite.config.js looks like this:

import {defineConfig} from 'vite';
import laravel from 'laravel-vite-plugin';
import livewire from '@defstudio/vite-livewire-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
            ],
            refresh: false,
        }),
        livewire({
            refresh: ['resources/css/app.css'],
        }),
    ],
});

Package.json

{
    "private": true,
    "type": "module",
    "scripts": {
        "dev": "vite",
        "build": "vite build"
    },
    "devDependencies": {
        "@alpinejs/focus": "^3.10.5",
        "@defstudio/vite-livewire-plugin": "^1.1.0",
        "@tailwindcss/forms": "^0.5.2",
        "@tailwindcss/typography": "^0.5.0",
        "alpinejs": "^3.0.6",
        "autoprefixer": "^10.4.7",
        "axios": "^1.1.2",
        "laravel-vite-plugin": "^0.7.5",
        "postcss": "^8.4.14",
        "tailwindcss": "^3.1.0",
        "vite": "^4.0.0"
    }
}

Laravel: 10.10.1
Jetstream: 3.2.0
Livewire: 2.12.3
Alpine.js: 3.12.1

Excluding Livewire views from the current full-page-reload behavior

Greetings,

The following are the only versions I managed to get Livewire hot-reloads working with:

And this is how I configured the vite.config.js file:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import livewire from '@defstudio/vite-livewire-plugin';

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/app.js',
        ]),
        {
            name: 'blade',
            handleHotUpdate({ file, server }) {
                if (
                    file.endsWith('.blade.php') &&
                    !file.includes('/livewire/')
                ) {
                    server.ws.send({
                        type: 'full-reload',
                        path: '*',
                    });
                }
            },
        },
        livewire({
            refresh: ['resources/css/app.css', 'resources/js/app.js'],
        }),
    ],
});

I had to downgrade them and used Freek's solution because I have no idea about accounting for this in the new versions:

files in /livewire/ should be excluded from blade hot reload.

Can you please teach me how? ๐Ÿ™ƒ

not supporting route model bind to protected variable

hello i have a full-page component like this :

    protected Product $product;

    public function mount(Product $product): void
    {
        $this->product = $product;
    }

the product will inject to the component using the laravel route model binding.

but when i use this plugin after any change it will show me 500 error :
Typed property ****::$product must not be accessed before initialization
the poroblem here is that this plugin can not handle route model binding on protected attribute on full-page components.

HMR doesn't rebuild tailwind

Steps

Here's a slimmed down repo I made for demo purposes based off the default laravel-9 installation.

  • Create new laravel+livewire+vite+tailwind project, add this plugin

  • Sail up, sail npm run dev, go to example-app.test

  • You should see a simple label and text area

Screen Shot 2022-08-18 at 5 02 27 PM

  • Enter text in textarea from browser, then make a code update inside show-posts.blade.php changing h2.innerText

from Make a post. to Make a post!!!

  • Livewire component updates without clearing the textarea (yay)

  • Add a tailwindcss class that didn't exist when you started build

  • <h1 class="text-3xl my-2"> to <h1 class="text-3xl my-2 text-[#FF0000]">

  • Livewire component updates, the HTML on the page changes, and the new class is on the H1 element (yay)

  • BUG: Tailwind did not rebuild and app.css has no such .text[#FF0000] class (boo)


  • Restart your npm run dev
  • Page reloads and text is now red

Volt Support

It appears reloads don't happen properly (or pages break) when using this with Volt. Is this expected to work? (Specifically volt anonymous components)

Vite 5 Support

Is there any work on Vite 5 support? Otherwise I can open a pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.