1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
diff --git a/packages/vscode-tailwindcss/src/extension.ts b/packages/vscode-tailwindcss/src/extension.ts
index b6c51c0c0f7ade2710eb85b59134849755bc0473..30cc692554f5d7df0422d7bebe2eee91cf7a009e 100755
--- a/packages/vscode-tailwindcss/src/extension.ts
+++ b/packages/vscode-tailwindcss/src/extension.ts
@@ -31,6 +31,7 @@ import { languages as defaultLanguages } from 'tailwindcss-language-service/src/util/languages'
import isObject from 'tailwindcss-language-service/src/util/isObject'
import { dedupe, equal } from 'tailwindcss-language-service/src/util/array'
import namedColors from 'color-name'
+import minimatch from 'minimatch'
const colorNames = Object.keys(namedColors)
@@ -82,6 +83,45 @@ const langs = Workspace.getConfiguration('tailwindCSS', folder).includeLanguages
return isObject(langs) ? langs : {}
}
+function getExcludePatterns(folder: WorkspaceFolder): string[] {
+ let globalExclude = Workspace.getConfiguration('files', folder).get('exclude')
+ let exclude = Object.entries(globalExclude)
+ .filter(([, value]) => value)
+ .map(([key]) => key)
+
+ return [
+ ...exclude,
+ ...(<string[]>Workspace.getConfiguration('tailwindCSS', folder).get('files.exclude')),
+ ]
+}
+
+function isExcluded(file: string, folder: WorkspaceFolder): boolean {
+ let exclude = getExcludePatterns(folder)
+
+ for (let pattern of exclude) {
+ if (minimatch(file, path.join(folder.uri.fsPath, pattern))) {
+ return true
+ }
+ }
+
+ return false
+}
+
+function mergeExcludes(settings, scope) {
+ // merge `files.exclude` into `tailwindCSS.files.exclude`
+ let globalExclude = Object.entries(Workspace.getConfiguration('files', scope).get('exclude'))
+ .filter(([, value]) => value)
+ .map(([key]) => key)
+
+ return {
+ ...settings,
+ files: {
+ ...settings.files,
+ exclude: [...globalExclude, ...settings.files.exclude],
+ },
+ }
+}
+
export async function activate(context: ExtensionContext) {
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
let prod = path.join('dist', 'server', 'tailwindServer.js')
@@ -108,8 +148,10 @@ let folder = Workspace.getWorkspaceFolder(uri)
if (!folder) {
return
}
- folder = getOuterMostWorkspaceFolder(folder)
- bootWorkspaceClient(folder)
+ if (!isExcluded(uri.fsPath, folder)) {
+ folder = getOuterMostWorkspaceFolder(folder)
+ bootWorkspaceClient(folder)
+ }
})
context.subscriptions.push(watcher)
@@ -180,7 +222,7 @@ }
let configuration = {
editor: Workspace.getConfiguration('editor', folder),
- tailwindCSS: Workspace.getConfiguration('tailwindCSS', folder),
+ tailwindCSS: mergeExcludes(Workspace.getConfiguration('tailwindCSS', folder), folder),
}
let inspectPort = configuration.tailwindCSS.get('inspectPort')
@@ -309,7 +351,13 @@ languageId: doc.languageId,
}
}
}
- return Workspace.getConfiguration(section, scope)
+ let settings = Workspace.getConfiguration(section, scope)
+
+ if (section === 'tailwindCSS') {
+ return mergeExcludes(settings, scope)
+ }
+
+ return settings
})
},
},
@@ -375,7 +423,7 @@ searchedFolders.add(folder.uri.toString())
let [configFile] = await Workspace.findFiles(
new RelativePattern(folder, `**/${CONFIG_FILE_GLOB}`),
- '**/node_modules/**',
+ `{${getExcludePatterns(folder).join(',')}}`,
1
)
|