Skip to content

Commit 0585d0f

Browse files
committed
utilise packages exported interface
1 parent b671be7 commit 0585d0f

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
"node": ">=14"
4646
},
4747
"dependencies": {
48-
"vite-plugin-full-reload": "^1.0.0"
48+
"vite-plugin-full-reload": "^1.0.1"
4949
}
5050
}

src/index.ts

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AddressInfo } from 'net'
33
import path from 'path'
44
import colors from 'picocolors'
55
import { Plugin, loadEnv, UserConfig, ConfigEnv, Manifest, ResolvedConfig, SSROptions, normalizePath, PluginOption } from 'vite'
6-
import fullReload from 'vite-plugin-full-reload'
6+
import fullReload, { Config as FullReloadConfig } from 'vite-plugin-full-reload'
77

88
interface PluginConfig {
99
/**
@@ -43,40 +43,12 @@ interface PluginConfig {
4343
* {@link https://github.com/ElMassimo/vite-plugin-full-reload}
4444
* @default false
4545
*/
46-
refresh?: boolean|string|string[]|FullReloadConfig|FullReloadConfig[]
46+
refresh?: boolean|string|string[]|RefreshConfig|RefreshConfig[]
4747
}
4848

49-
interface FullReloadConfig {
49+
interface RefreshConfig {
5050
paths: string[],
51-
config?: {
52-
/**
53-
* Whether full reload should happen regardless of the file path.
54-
*
55-
* @default true
56-
*/
57-
always?: boolean
58-
59-
/**
60-
* How many milliseconds to wait before reloading the page after a file change.
61-
*
62-
* @default 0
63-
*/
64-
delay?: number
65-
66-
/**
67-
* Whether to log when a file change triggers a full reload.
68-
*
69-
* @default true
70-
*/
71-
log?: boolean
72-
73-
/**
74-
* Files will be resolved against this path.
75-
*
76-
* @default process.cwd()
77-
*/
78-
root?: string
79-
}
51+
config?: FullReloadConfig,
8052
}
8153

8254
interface LaravelPlugin extends Plugin {
@@ -383,10 +355,10 @@ function resolveFullReloadConfig({ refresh: config }: Required<PluginConfig>): P
383355
}
384356

385357
if (config.some(c => typeof c === 'string')) {
386-
config = [{ paths: config }] as FullReloadConfig[]
358+
config = [{ paths: config }] as RefreshConfig[]
387359
}
388360

389-
return (config as FullReloadConfig[]).flatMap(c => {
361+
return (config as RefreshConfig[]).flatMap(c => {
390362
const plugin = fullReload(c.paths, c.config)
391363

392364
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */

0 commit comments

Comments
 (0)