Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-live-reload

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-live-reload - npm Package Compare versions

Comparing version 2.0.0-beta.0 to 2.0.0

15

dist/index.js

@@ -7,2 +7,3 @@ 'use strict';

var chalk = require('chalk');
var path = require('path');

@@ -13,14 +14,18 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
function getShortName(file, root) {
return file.startsWith(root + "/") ? path__default['default'].posix.relative(root, file) : file;
}
var index = (paths, config = {}) => ({
name: "vite-plugin-live-reload",
configureServer({ws, config: {root}}) {
const reload = (path, action) => {
configureServer({ws, config: {root, logger}}) {
const reload = (path2) => {
var _a;
ws.send({type: "full-reload", path});
ws.send({type: "full-reload", path: path2});
if ((_a = config.log) != null ? _a : true) {
console.log(chalk__default['default'].green(`[vite-live-reload] `) + `${path} ${action}.`);
logger.info(chalk__default['default'].green(`page reload `) + chalk__default['default'].dim(getShortName(path2, root)), {clear: true, timestamp: true});
}
};
chokidar__default['default'].watch(paths, {cwd: root, ignoreInitial: true, ...config}).on("add", (path) => reload(path, "added")).on("change", (path) => reload(path, "changed"));
chokidar__default['default'].watch(paths, {cwd: root, ignoreInitial: true, ...config}).on("add", reload).on("change", reload);
}

@@ -27,0 +32,0 @@ });

{
"name": "vite-plugin-live-reload",
"version": "2.0.0-beta.0",
"version": "2.0.0",
"description": "A *very* simple live reloading plugin for vite.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import { Plugin, ViteDevServer } from 'vite'
import chokidar, { WatchOptions } from 'chokidar'
import chalk from 'chalk'
import path from 'path'
// https://github.com/vitejs/vite/blob/03b323d39cafe2baabef74e6051a9640add82590/packages/vite/src/node/server/hmr.ts
function getShortName(file: string, root: string) {
return file.startsWith(root + '/') ? path.posix.relative(root, file) : file
}
/** Plugin configuration */

@@ -22,14 +28,18 @@ interface Config extends WatchOptions {

configureServer({ ws, config: { root } }: ViteDevServer) {
const reload = (path: string, action: string) => {
configureServer({ ws, config: { root, logger } }: ViteDevServer) {
const reload = (path: string) => {
ws.send({ type: 'full-reload', path })
if (config.log ?? true) {
console.log(chalk.green(`[vite-live-reload] `) + `${path} ${action}.`)
logger.info(
chalk.green(`page reload `) + chalk.dim(getShortName(path, root)),
{ clear: true, timestamp: true }
)
}
}
chokidar
.watch(paths, { cwd: root, ignoreInitial: true, ...config })
.on('add', path => reload(path, 'added'))
.on('change', path => reload(path, 'changed'))
}
.on('add', reload)
.on('change', reload)
}
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc