Skip to content

Commit

Permalink
fix: enable css and asset addWatchFile at dev
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin committed Aug 2, 2024
1 parent 04963e1 commit ec3e924
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
// raw requests, read from disk
if (rawRE.test(id)) {
const file = checkPublicFile(id, config) || cleanUrl(id)
// this.addWatchFile(file)
if (config.command !== 'build') {
// @ts-expect-error
this.addWatchFile(file)
}
// raw query, read file and return as string
return `export default ${JSON.stringify(
await fsp.readFile(file, 'utf-8'),
Expand Down
13 changes: 7 additions & 6 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
const {
code: css,
modules,
//deps,
deps,
map,
} = await compileCSS(
id,
Expand All @@ -379,11 +379,12 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
moduleCache.set(id, modules)
}

// if (deps) {
// for (const file of deps) {
// this.addWatchFile(file)
// }
// }
if (deps && !isBuild) {
for (const file of deps) {
// @ts-expect-error
this.addWatchFile(file)
}
}

return {
code: css,
Expand Down

0 comments on commit ec3e924

Please sign in to comment.