Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vscode): setting default presets for creating each context #1114

Merged
merged 1 commit into from Jun 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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