Skip to content

Commit

Permalink
Merge pull request #13 from Applelo/dev
Browse files Browse the repository at this point in the history
Version 3.0.0
  • Loading branch information
Applelo authored Feb 2, 2024
2 parents 19c2469 + 088a139 commit b55cf98
Show file tree
Hide file tree
Showing 18 changed files with 1,602 additions and 1,461 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,26 @@ jobs:

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

steps:
- uses: actions/checkout@v3

- name: Install pnpm (node 14, pnpm 7)
if: matrix.node_version == 14
uses: pnpm/[email protected]
with:
version: 7

- name: Install pnpm
if: matrix.node_version != 14
uses: pnpm/[email protected]

- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ matrix.node_version }}
cache: pnpm

- name: Install
Expand All @@ -56,6 +49,13 @@ jobs:
- name: Test
run: pnpm test

- name: Upload artifacts on failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-project-${{ matrix.os }}-${{ matrix.node_version }}
path: test/dist/

coverage:
runs-on: ubuntu-latest
name: Coverage
Expand Down
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

52 changes: 44 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Add [BrowserSync](https://browsersync.io) in your Vite project.
- ✨ All the [BrowserSync features](https://browsersync.io/)
- 🙌 Support for BrowserSync `proxy` and `snippet` mode
- 🔥 Liberty to manage BrowserSync options
- 🎛️ Can run on `dev`, `preview` or `build --watch`

## 📦 Install

Expand All @@ -37,7 +38,7 @@ bun add -D vite-plugin-browser-sync

## 👨‍💻 Usage

BrowserSync starts alongside your Vite Server. By default, it uses the `proxy` mode of BrowserSync based on your Vite server options : no need to pass any options to make it work !
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!

```js
// vite.config.js / vite.config.ts
Expand All @@ -57,11 +58,13 @@ import VitePluginBrowserSync from 'vite-plugin-browser-sync'
export default {
plugins: [
VitePluginBrowserSync({
bs: {
ui: {
port: 8080
},
notify: false
dev: {
bs: {
ui: {
port: 8080
},
notify: false
}
}
})
]
Expand All @@ -77,7 +80,40 @@ import VitePluginBrowserSync from 'vite-plugin-browser-sync'
export default {
plugins: [
VitePluginBrowserSync({
mode: 'snippet'
dev: {
mode: 'snippet'
}
})
]
}
```

You can also enable the plugin on `vite build --watch` mode and `vite preview` mode.

> [!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.
> - In `preview`, only the `proxy` mode is supported since it will not inject the `snippet`.
```js
// vite.config.js / vite.config.ts
import VitePluginBrowserSync from 'vite-plugin-browser-sync'

export default {
plugins: [
VitePluginBrowserSync({
dev: {
enable: false,
},
preview: {
enable: true,
},
buildWatch: {
enable: true,
bs: {
proxy: 'http://localhost:3000',
}
}
})
]
}
Expand Down Expand Up @@ -112,4 +148,4 @@ If you want to change the overrided options you free to do so via the `bs` objec

## 👨‍💼 Licence

GPL-3.0
MIT
5 changes: 3 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"type": "module",
"version": "0.0.0",
"private": true,
"packageManager": "pnpm@8.10.2",
"packageManager": "pnpm@8.15.1",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:watch": "vite build --watch",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^5.3.3",
"vite": "^5.0.6",
"vite": "^5.0.12",
"vite-plugin-browser-sync": "workspace:*"
}
}
30 changes: 27 additions & 3 deletions demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
import VitePluginBrowserSync from 'vite-plugin-browser-sync'
import { defineConfig } from 'vite'

export default {
plugins: [VitePluginBrowserSync()],
}
export default defineConfig({
// build: {
// watch: {},
// },
plugins: [
VitePluginBrowserSync({
// preview: {
// enable: true,
// bs: {
// proxy: 'http://localhost:3000',
// },
// },
buildWatch: {
enable: true,
// mode: 'snippet',
bs: {
// server: 'dist',
// proxy: 'http://localhost:3000',
// proxy: {
// target: 'http://localhost:3000',
// },
},
},
}),
],
})
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "vite-plugin-browser-sync",
"type": "module",
"version": "2.0.1",
"packageManager": "pnpm@8.11.0",
"version": "3.0.0",
"packageManager": "pnpm@8.15.1",
"description": "Add BrowserSync in your Vite project",
"author": "Applelo",
"license": "GPL-3.0",
"license": "MIT",
"homepage": "https://github.com/Applelo/vite-plugin-browser-sync",
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,8 +38,8 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"build": "tsup src/index.ts --dts --format cjs,esm",
"build:watch": "tsup src/index.ts --watch --dts --format cjs,esm",
"build": "tsup src/index.ts",
"build:watch": "tsup src/index.ts --watch",
"typecheck": "tsc --noEmit --skipLibCheck",
"test": "vitest",
"coverage": "vitest run --coverage",
Expand All @@ -50,17 +50,18 @@
},
"dependencies": {
"@types/browser-sync": "^2.29.0",
"browser-sync": "^2.29.3",
"browser-sync": "^3.0.2",
"kolorist": "^1.8.0"
},
"devDependencies": {
"@antfu/eslint-config": "^2.4.2",
"@vitest/coverage-v8": "^1.0.2",
"eslint": "^8.55.0",
"playwright": "^1.40.1",
"@antfu/eslint-config": "^2.6.3",
"@vitest/coverage-v8": "^1.2.2",
"eslint": "^8.56.0",
"playwright": "^1.41.2",
"rollup": "^4.9.6",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vite": "^5.0.6",
"vitest": "^1.0.2"
"vite": "^5.0.12",
"vitest": "^1.2.2"
}
}
Loading

0 comments on commit b55cf98

Please sign in to comment.