Skip to content

Commit 88c81b7

Browse files
committed
fix: enable css and asset addWatchFile at dev
1 parent f66be46 commit 88c81b7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ 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-
// this.addWatchFile(file)
178+
if (config.command !== 'build') {
179+
// @ts-expect-error
180+
this.addWatchFile(file)
181+
}
179182
// raw query, read file and return as string
180183
return `export default ${JSON.stringify(
181184
await fsp.readFile(file, 'utf-8'),

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
367367
const {
368368
code: css,
369369
modules,
370-
//deps,
370+
deps,
371371
map,
372372
} = await compileCSS(
373373
id,
@@ -380,11 +380,12 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
380380
moduleCache.set(id, modules)
381381
}
382382

383-
// if (deps) {
384-
// for (const file of deps) {
385-
// this.addWatchFile(file)
386-
// }
387-
// }
383+
if (deps && !isBuild) {
384+
for (const file of deps) {
385+
// @ts-expect-error
386+
this.addWatchFile(file)
387+
}
388+
}
388389

389390
return {
390391
code: css,

0 commit comments

Comments
 (0)