vite-plugin-live-reload
Advanced tools
Comparing version 0.1.2 to 2.0.0-beta.0
@@ -5,23 +5,22 @@ 'use strict'; | ||
var chokidar2 = require('chokidar'); | ||
var chalk2 = require('chalk'); | ||
var chokidar = require('chokidar'); | ||
var chalk = require('chalk'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var chokidar2__default = /*#__PURE__*/_interopDefaultLegacy(chokidar2); | ||
var chalk2__default = /*#__PURE__*/_interopDefaultLegacy(chalk2); | ||
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar); | ||
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk); | ||
var index = (paths, config = {}) => ({ | ||
configureServer: [ | ||
({watcher, config: {root}}) => { | ||
const reload = (path, action) => { | ||
var _a; | ||
watcher.send({type: "full-reload", path}); | ||
if ((_a = config.log) != null ? _a : true) { | ||
console.log(chalk2__default['default'].green(`[vite-live-reload] `) + `${path} ${action}.`); | ||
} | ||
}; | ||
chokidar2__default['default'].watch(paths, {cwd: root, ignoreInitial: true, ...config}).on("add", (path) => reload(path, "added")).on("change", (path) => reload(path, "changed")); | ||
} | ||
] | ||
name: "vite-plugin-live-reload", | ||
configureServer({ws, config: {root}}) { | ||
const reload = (path, action) => { | ||
var _a; | ||
ws.send({type: "full-reload", path}); | ||
if ((_a = config.log) != null ? _a : true) { | ||
console.log(chalk__default['default'].green(`[vite-live-reload] `) + `${path} ${action}.`); | ||
} | ||
}; | ||
chokidar__default['default'].watch(paths, {cwd: root, ignoreInitial: true, ...config}).on("add", (path) => reload(path, "added")).on("change", (path) => reload(path, "changed")); | ||
} | ||
}); | ||
@@ -28,0 +27,0 @@ |
{ | ||
"name": "vite-plugin-live-reload", | ||
"version": "0.1.2", | ||
"version": "2.0.0-beta.0", | ||
"description": "A *very* simple live reloading plugin for vite.", | ||
@@ -26,15 +26,15 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/arnoson/vite-plugin-live-reload#readme", | ||
"peerDependencies": { | ||
"chokidar": "*", | ||
"chalk": "*" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "^0.8.22", | ||
"rollup": "^2.34.2", | ||
"@types/node": "^14.14.20", | ||
"esbuild": "^0.8.31", | ||
"rollup": "^2.36.1", | ||
"rollup-plugin-dts": "^2.0.1", | ||
"rollup-plugin-esbuild": "^2.6.1", | ||
"typescript": "^4.1.3", | ||
"vite": "^1.0.0-rc.13" | ||
"vite": "^2.0.0-beta.27" | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"chokidar": "^3.5.0" | ||
} | ||
} |
@@ -6,2 +6,4 @@ # vite-plugin-live-reload | ||
I use this configuration when working with [Kirby CMS](https://getkirby.com/) (assuming your Kirby site is inside a `public` folder). | ||
Note: the paths you are watching are relative to vite's root folder. | ||
```js | ||
@@ -8,0 +10,0 @@ // vite.config.js |
@@ -1,3 +0,3 @@ | ||
import { Plugin } from 'vite' | ||
import chokidar, { WatchOptions} from 'chokidar' | ||
import { Plugin, ViteDevServer } from 'vite' | ||
import chokidar, { WatchOptions } from 'chokidar' | ||
import chalk from 'chalk' | ||
@@ -20,19 +20,16 @@ | ||
): Plugin => ({ | ||
configureServer: [ | ||
({ watcher, config: { root } }) => { | ||
const reload = (path: string, action: string) => { | ||
// We utilize the `send()` method of the `watcher` instance. I'm not | ||
// sure if this is the correct way to send messages to the client but it | ||
// works great. | ||
watcher.send({ type: 'full-reload', path }) | ||
if (config.log ?? true) { | ||
console.log(chalk.green(`[vite-live-reload] `) + `${path} ${action}.`) | ||
} | ||
name: 'vite-plugin-live-reload', | ||
configureServer({ ws, config: { root } }: ViteDevServer) { | ||
const reload = (path: string, action: string) => { | ||
ws.send({ type: 'full-reload', path }) | ||
if (config.log ?? true) { | ||
console.log(chalk.green(`[vite-live-reload] `) + `${path} ${action}.`) | ||
} | ||
chokidar | ||
.watch(paths, { cwd: root, ignoreInitial: true, ...config }) | ||
.on('add', path => reload(path, 'added')) | ||
.on('change', path => reload(path, 'changed')) | ||
} | ||
] | ||
chokidar | ||
.watch(paths, { cwd: root, ignoreInitial: true, ...config }) | ||
.on('add', path => reload(path, 'added')) | ||
.on('change', path => reload(path, 'changed')) | ||
} | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
5067
7
87
+ Addedchalk@^4.1.0
+ Addedchokidar@^3.5.0
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removedchalk@5.4.1(transitive)
- Removedchokidar@4.0.3(transitive)
- Removedreaddirp@4.0.2(transitive)