Applelo / vite-plugin-browser-sync

Add BrowserSync in your Vite project
MIT License
67 stars 3 forks source link

Use in Astro Project #21

Closed CraigTheNerd closed 4 months ago

CraigTheNerd commented 4 months ago

Would it be possible to use this plugin in an Astro project.

I tried following the Astro docs on how to install Vite plugins but I can't get it working.

Here is my astro.config.mjs

import { defineConfig } from 'astro/config';
import VitePluginBrowserSync from 'vite-plugin-browser-sync'

// https://astro.build/config
export default defineConfig({
    vite: {
        plugins: [
            VitePluginBrowserSync({
                dev: {
                    bs: {
                        ui: {
                            port: 8080
                        },
                        notify: false
                    }
                }
            })
        ]
    }
});

I would appreciate any help, thanks!

Applelo commented 4 months ago

Hi 👋 It seems the plugin is not working on Astro 😶 I will try to find why 🤔

CraigTheNerd commented 4 months ago

Thanks so much, would appreciate it if you get it working. Please keep me posted. Thanks!!!

CraigTheNerd commented 4 months ago

Didn't mean to close the issue, definitely still open and waiting for feedback and solution thanks

Applelo commented 4 months ago

I will publish a new version soon that support AstroJS.

For the small story, Astro doesn't pass on dev env.isPreview so the plugin was not applied. The second problem with Astro, it uses the Vite Dev Server but doesn't use the logger from ViteJS so the plugin cannot hook and print urls information.

Applelo commented 4 months ago

You can try the last version, feel free to reopen this issue if necessary 😄