Skip to content

Commit

Permalink
fix(vscode): setting default presets for creating each context (#1114)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyPi committed Jun 19, 2022
1 parent 1d26827 commit 8426174
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/vscode/src/contextLoader.ts
@@ -1,7 +1,7 @@
import { readdir } from 'fs/promises'
import path from 'path'
import fs from 'fs'
import type { UnocssPluginContext, UserConfig } from '@unocss/core'
import type { UnocssPluginContext, UserConfig, UserConfigDefaults } from '@unocss/core'
import { notNull } from '@unocss/core'
import { sourceObjectFields, sourcePluginFactory } from 'unconfig/presets'
import presetUno from '@unocss/preset-uno'
Expand All @@ -19,6 +19,10 @@ export class ContextLoader {

private fileContextCache = new Map<string, UnocssPluginContext<UserConfig<any>> | null>()
private configExistsCache = new Map<string, boolean>()
private defaultUnocssConfig: UserConfigDefaults = {
presets: [presetUno()],
}

public events = createNanoEvents<{
reload: () => void
contextLoaded: (context: UnocssPluginContext<UserConfig<any>>) => void
Expand All @@ -28,11 +32,7 @@ export class ContextLoader {

constructor(cwd: string) {
this.cwd = cwd
this.defaultContext = createContext({
presets: [
presetUno(),
],
})
this.defaultContext = createContext(this.defaultUnocssConfig)

this.ready = this.reload()
.then(async () => {
Expand Down Expand Up @@ -91,7 +91,7 @@ export class ContextLoader {
log.appendLine(`[info] Resolving config for ${dir}`)
const context = createContext(
dir,
undefined,
this.defaultUnocssConfig,
[
sourcePluginFactory({
files: [
Expand Down

0 comments on commit 8426174

Please sign in to comment.