Skip to content

Commit 9b2eb75

Browse files
committed
chore: enable addWatchFile
1 parent 5342ac5 commit 9b2eb75

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

packages/vite/src/node/plugins/asset.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
175175
// raw requests, read from disk
176176
if (rawRE.test(id)) {
177177
const file = checkPublicFile(id, config) || cleanUrl(id)
178-
if (config.command !== 'build') {
179-
this.addWatchFile(file)
180-
}
178+
this.addWatchFile(file)
181179
// raw query, read file and return as string
182180
return {
183181
code: `export default ${JSON.stringify(

packages/vite/src/node/plugins/css.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
380380
moduleCache.set(id, modules)
381381
}
382382

383-
if (deps && !isBuild) {
383+
if (deps) {
384384
for (const file of deps) {
385385
this.addWatchFile(file)
386386
}

packages/vite/src/node/plugins/loadFallback.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export function loadFallbackPlugin(): Plugin {
1212
try {
1313
const cleanedId = cleanUrl(id)
1414
const content = await fsp.readFile(cleanedId, 'utf-8')
15-
// this.addWatchFile(cleanedId)
15+
this.addWatchFile(cleanedId)
1616
return content
1717
} catch (e) {
1818
const content = await fsp.readFile(id, 'utf-8')
19-
// this.addWatchFile(id)
19+
this.addWatchFile(id)
2020
return content
2121
}
2222
},

playground/transform-plugin/vite.config.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ let transformCount = 1
77
const transformPlugin = {
88
name: 'transform',
99
load(id) {
10-
if (id === file && typeof this.addWatchFile === 'function') {
10+
if (id === file) {
1111
// Ensure `index.js` is reloaded if 'plugin-dep-load.js' is changed
1212
this.addWatchFile('./plugin-dep-load.js')
1313
}
1414
},
1515
transform(code, id) {
1616
if (id === file) {
17-
if (typeof this.addWatchFile === 'function'){
18-
// Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed
19-
this.addWatchFile('./plugin-dep.js')
20-
}
17+
// Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed
18+
this.addWatchFile('./plugin-dep.js')
2119

2220
return `
2321
// Inject TRANSFORM_COUNT

0 commit comments

Comments
 (0)