Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:

strategy:
matrix:
node_version: [18, 20]
node_version: [18, 20, 22]
os: [ubuntu-latest]
include:
# Active LTS + other OS
- os: macos-latest
node_version: 20
# - os: macos-latest
# node_version: 22
- os: windows-latest
node_version: 20
node_version: 22
fail-fast: false

steps:
Expand Down Expand Up @@ -67,10 +67,10 @@ jobs:

- uses: pnpm/action-setup@v4

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: Install
Expand All @@ -92,7 +92,7 @@ jobs:

lint:
runs-on: ubuntu-latest
name: 'Lint: node-20, ubuntu-latest'
name: 'Lint: node-22, ubuntu-latest'

steps:
- uses: actions/checkout@v4
Expand All @@ -101,10 +101,10 @@ jobs:

- uses: pnpm/action-setup@v4

- name: Set node version to 20
- name: Set node version to 22
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js 20
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
cache: pnpm

- name: Install
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# vite-plugin-browser-sync

Add [BrowserSync](https://browsersync.io) in your Vite project.
Add [BrowserSync](https://browsersync.io) to your Vite project.

> This plugin supports Vite 5 and 6.
> This plugin supports Vite 6 and 7.

<p align="center">
<a href="https://github.com/Applelo/vite-plugin-browser-sync/blob/main/screenshot.png?raw=true">
Expand All @@ -14,11 +14,11 @@ Add [BrowserSync](https://browsersync.io) in your Vite project.

## 🚀 Features

- ⚡ Fully integrate in your ViteJS environment
- ⚡ Fully integrated in your ViteJS environment
- 👌 Zero config available for common use cases
- ✨ All the [BrowserSync features](https://browsersync.io/)
- 🙌 Support for BrowserSync `proxy` and `snippet` mode
- 🔥 Liberty to manage BrowserSync options
- 🔥 Freedom to manage BrowserSync options
- 🎛️ Can run on `dev`, `preview` or `build --watch`

## 📦 Install
Expand All @@ -38,7 +38,7 @@ bun add -D vite-plugin-browser-sync

## 👨‍💻 Usage

By default, BrowserSync will start alongside your Vite Server in `dev`. It uses the `proxy` mode of BrowserSync based on your Vite server options : no need to pass any options to make it works!
By default, BrowserSync will start alongside your Vite Server in `dev`. It uses the `proxy` mode of BrowserSync based on your Vite server options: no need to pass any options to make it work!

```js
// vite.config.js / vite.config.ts
Expand All @@ -49,7 +49,7 @@ export default {
}
```

If you want to manage BrowserSync or [override default behavior of this plugin](https://github.com/Applelo/vite-plugin-browser-sync#vite-plugin-browser-sync-options-for-browsersync), you can pass a `bs` object with your [BrowserSync options](https://browsersync.io/docs/options) in it :
If you want to manage BrowserSync or [override default behavior of this plugin](https://github.com/Applelo/vite-plugin-browser-sync#vite-plugin-browser-sync-options-for-browsersync), you can pass a `bs` object with your [BrowserSync options](https://browsersync.io/docs/options) in it:

```js
// vite.config.js / vite.config.ts
Expand Down Expand Up @@ -92,7 +92,7 @@ You can also enable the plugin on `vite build --watch` mode and `vite preview` m

> [!IMPORTANT]
> - In `buildWatch`, if you use the default `proxy` mode you need to set the `bs` object.
> - `snippet` mode is available in `buildWatch` but it is not recommanded to use since it update your `index.html` file.
> - `snippet` mode is available in `buildWatch` but it is not recommended to use since it updates your `index.html` file.
> - In `preview`, only the `proxy` mode is supported since it will not inject the `snippet`.

```js
Expand Down Expand Up @@ -120,35 +120,35 @@ export default {
```

> [!NOTE]
> For Astro user, this plugin is not working in preview mode because of [overrides made by Astro](https://github.com/withastro/astro/blob/a6c4e6754493e7af5c953b644c6a19461f15467b/packages/astro/src/core/preview/static-preview-server.ts#L40).
> For Astro users, this plugin does not work in preview mode because of [overrides made by Astro](https://github.com/withastro/astro/blob/a6c4e6754493e7af5c953b644c6a19461f15467b/packages/astro/src/core/preview/static-preview-server.ts#L40).

## vite-plugin-browser-sync options for BrowserSync

This plugin overrides default options from BrowserSync to doesn't duplicate behaviors already handle by ViteJS. Futhermore, your ViteJS config are synced with BrowserSync.
This plugin overrides default options from BrowserSync to avoid duplicating behaviors already handled by ViteJS. Furthermore, your ViteJS config is synced with BrowserSync.

If you want to change the overrided options you free to do so via the `bs` object.
If you want to change the overridden options you are free to do so via the `bs` object.

| Option | Why | dev | buildWatch | preview |
|-----------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|:---:|:----------:|:-------:|
| [logLevel](https://browsersync.io/docs/options#option-logLevel) | Set to `silent`, use ViteJS [printUrls](https://vitejs.dev/guide/api-javascript.html#createserver) to display BrowserSync info | ✔️ | ✔️ | ✔️ |
| [open](https://browsersync.io/docs/options#option-open) | Apply ViteJS [open option](https://vitejs.dev/config/server-options.html#server-open) | ✔️ | | ✔️ |
| [codeSync](https://browsersync.io/docs/options#option-codeSync) | Disabled because it is already handle by ViteJS | ✔️ | | |
| [codeSync](https://browsersync.io/docs/options#option-codeSync) | Disabled because it is already handled by ViteJS | ✔️ | | |
| [online](https://browsersync.io/docs/options#option-online) | Synced with the [server host option](https://vitejs.dev/config/server-options.html#server-host) | ✔️ | | ✔️ |

### For `proxy` mode

| Option | Why | dev | buildWatch | preview |
|------------------------------------------------------------------|-----------------------------------------------|:---:|------------|:-------:|
| [proxy.target](https://browsersync.io/docs/options#option-proxy) | Inject the right url from ViteJS | ✔️ | | ✔️ |
| [proxy.ws](https://browsersync.io/docs/options#option-proxy) | Force websocket proxy to make work ViteJS HMR | ✔️ | | ✔️ |
| [proxy.ws](https://browsersync.io/docs/options#option-proxy) | Force websocket proxy to make ViteJS HMR work | ✔️ | | ✔️ |

### For `snippet` mode

| Option | Why |
| ------------------------------------------------------------------- | ------------------------------------------------------ |
| [logSnippet](https://browsersync.io/docs/options#option-logSnippet) | Handle by the plugin so no need to display the snippet |
| [snippet](https://browsersync.io/docs/options#option-snippet) | The snippet injection is handle by the plugin |
| [logSnippet](https://browsersync.io/docs/options#option-logSnippet) | Handled by the plugin so no need to display the snippet |
| [snippet](https://browsersync.io/docs/options#option-snippet) | The snippet injection is handled by the plugin |

## 👨‍💼 Licence
## 👨‍💼 License

MIT
5 changes: 2 additions & 3 deletions demo/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"type": "module",
"version": "0.0.1",
"private": true,
"packageManager": "pnpm@9.15.0",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
Expand All @@ -13,8 +12,8 @@
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"astro": "^5.0.5",
"typescript": "^5.7.2",
"astro": "^5.13.2",
"typescript": "^5.9.2",
"vite-plugin-browser-sync": "workspace:*"
}
}
24 changes: 0 additions & 24 deletions demo/basic-vite5/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions demo/basic-vite5/favicon.svg

This file was deleted.

27 changes: 0 additions & 27 deletions demo/basic-vite5/index.html

This file was deleted.

18 changes: 0 additions & 18 deletions demo/basic-vite5/package.json

This file was deleted.

1 change: 0 additions & 1 deletion demo/basic-vite5/public/vite.svg

This file was deleted.

16 changes: 0 additions & 16 deletions demo/basic-vite5/src/main.ts

This file was deleted.

27 changes: 0 additions & 27 deletions demo/basic-vite5/src/style.css

This file was deleted.

1 change: 0 additions & 1 deletion demo/basic-vite5/src/typescript.svg

This file was deleted.

1 change: 0 additions & 1 deletion demo/basic-vite5/src/vite-env.d.ts

This file was deleted.

20 changes: 0 additions & 20 deletions demo/basic-vite5/tsconfig.json

This file was deleted.

35 changes: 0 additions & 35 deletions demo/basic-vite5/vite.config.ts

This file was deleted.

Loading
Loading