From 8426174d8f6950692811ce8fdffd850ebd16af48 Mon Sep 17 00:00:00 2001 From: TrickyPi <33021497+TrickyPi@users.noreply.github.com> Date: Sun, 19 Jun 2022 13:31:45 +0800 Subject: [PATCH] fix(vscode): setting default presets for creating each context (#1114) --- packages/vscode/src/contextLoader.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/vscode/src/contextLoader.ts b/packages/vscode/src/contextLoader.ts index c3ae3feca2..dc7510c95b 100644 --- a/packages/vscode/src/contextLoader.ts +++ b/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' @@ -19,6 +19,10 @@ export class ContextLoader { private fileContextCache = new Map> | null>() private configExistsCache = new Map() + private defaultUnocssConfig: UserConfigDefaults = { + presets: [presetUno()], + } + public events = createNanoEvents<{ reload: () => void contextLoaded: (context: UnocssPluginContext>) => void @@ -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 () => { @@ -91,7 +91,7 @@ export class ContextLoader { log.appendLine(`[info] Resolving config for ${dir}`) const context = createContext( dir, - undefined, + this.defaultUnocssConfig, [ sourcePluginFactory({ files: [