Skip to content

Commit

Permalink
Revert "fix(vite): update @apply when config changed (#837)"
Browse files Browse the repository at this point in the history
This reverts commit 336c5b9.
  • Loading branch information
antfu committed May 1, 2022
1 parent 09a6d7e commit 306340d
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions packages/vite/src/modes/global/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Plugin, ViteDevServer, ResolvedConfig as ViteResolvedConfig } from 'vite'
import type { UnocssPluginContext } from '@unocss/core'
import { LAYER_MARK_ALL, getPath, regexCssId, resolveId } from '../../../../plugins-common'
import { LAYER_MARK_ALL, getPath, resolveId } from '../../../../plugins-common'

const WARN_TIMEOUT = 20000
const WS_EVENT_PREFIX = 'unocss:hmr'
Expand All @@ -11,7 +11,6 @@ export function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter

const tasks: Promise<any>[] = []
const entries = new Map<string, string>()
const cssModules = new Set<string>()

let invalidateTimer: any
let lastUpdate = Date.now()
Expand All @@ -28,12 +27,8 @@ export function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter
}

function invalidate(timer = 10) {
const ids = [
...entries.keys(),
...cssModules.keys(),
]
for (const server of servers) {
for (const id of ids) {
for (const id of entries.keys()) {
const mod = server.moduleGraph.getModuleById(id)
if (!mod)
continue
Expand All @@ -46,14 +41,10 @@ export function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter

function sendUpdate() {
lastUpdate = Date.now()
const ids = [
...entries.keys(),
...cssModules.keys(),
]
for (const server of servers) {
server.ws.send({
type: 'update',
updates: Array.from(ids).map(i => ({
updates: Array.from(entries.keys()).map(i => ({
acceptedPath: i,
path: i,
timestamp: lastUpdate,
Expand Down Expand Up @@ -118,8 +109,6 @@ export function GlobalModeDevPlugin({ uno, tokens, onInvalidate, extract, filter
entries.set(entry.id, entry.layer)
return entry.id
}
if (id.match(regexCssId))
cssModules.add(id)
},
async load(id) {
const layer = entries.get(getPath(id))
Expand Down

0 comments on commit 306340d

Please sign in to comment.