@@ -34,7 +34,7 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
34
34
//
35
35
// These lookups can take a bit so we cache them. This is especially important
36
36
// for files with lots of embedded languages (e.g. Vue bindings).
37
- let configDir = await resolvePrettierConfigPath ( options . filepath )
37
+ let [ configDir , configPath ] = await resolvePrettierConfigPath ( options . filepath )
38
38
39
39
// Locate Tailwind CSS itself
40
40
//
@@ -48,7 +48,7 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
48
48
// We resolve this relative to the config file because it is *required*
49
49
// to work with a project's custom config. Given that, resolving it
50
50
// relative to where the path is defined makes the most sense.
51
- let stylesheet = resolveStylesheet ( options , configDir )
51
+ let stylesheet = resolveStylesheet ( options , configDir , configPath )
52
52
53
53
// Locate *explicit* v3 configs relative to the prettier config file
54
54
//
@@ -91,7 +91,8 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
91
91
// Warn them about this and use the bundled v4.
92
92
console . error (
93
93
'explicit-stylesheet-and-config-together' ,
94
- 'You have specified a Tailwind CSS stylesheet and a Tailwind CSS config at the same time. Use tailwindStylesheet unless you are using v3. Preferring the stylesheet.' ,
94
+ configPath ?? '' ,
95
+ `You have specified a Tailwind CSS stylesheet and a Tailwind CSS config at the same time. Use tailwindStylesheet unless you are using v3. Preferring the stylesheet.` ,
95
96
)
96
97
}
97
98
@@ -105,6 +106,7 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
105
106
mod = null
106
107
console . error (
107
108
'stylesheet-unsupported' ,
109
+ configPath ?? '' ,
108
110
'You have specified a Tailwind CSS stylesheet but your installed version of Tailwind CSS does not support this feature.' ,
109
111
)
110
112
}
@@ -128,7 +130,7 @@ export async function getTailwindConfig(options: ParserOptions): Promise<any> {
128
130
129
131
let prettierConfigCache = expiringMap < string , Promise < string | null > > ( 10_000 )
130
132
131
- async function resolvePrettierConfigPath ( filePath : string ) : Promise < string > {
133
+ async function resolvePrettierConfigPath ( filePath : string ) : Promise < [ string , string | null ] > {
132
134
let prettierConfig = await prettierConfigCache . remember ( filePath , async ( ) => {
133
135
try {
134
136
return await prettier . resolveConfigFile ( filePath )
@@ -139,7 +141,7 @@ async function resolvePrettierConfigPath(filePath: string): Promise<string> {
139
141
}
140
142
} )
141
143
142
- return prettierConfig ? path . dirname ( prettierConfig ) : process . cwd ( )
144
+ return prettierConfig ? [ path . dirname ( prettierConfig ) , prettierConfig ] : [ process . cwd ( ) , null ]
143
145
}
144
146
145
147
let resolvedModCache = expiringMap < string , Promise < [ any | null , string | null ] > > ( 10_000 )
@@ -193,7 +195,7 @@ function findClosestJsConfig(inputDir: string): string | null {
193
195
return configPath
194
196
}
195
197
196
- function resolveStylesheet ( options : ParserOptions , baseDir : string ) : string | null {
198
+ function resolveStylesheet ( options : ParserOptions , baseDir : string , configPath : string | null ) : string | null {
197
199
if ( options . tailwindStylesheet ) {
198
200
if (
199
201
options . tailwindStylesheet . endsWith ( '.js' ) ||
@@ -205,6 +207,7 @@ function resolveStylesheet(options: ParserOptions, baseDir: string): string | nu
205
207
) {
206
208
console . error (
207
209
'stylesheet-is-js-file' ,
210
+ configPath ?? '' ,
208
211
"Your `tailwindStylesheet` option points to a JS/TS config file. You must point to your project's `.css` file for v4 projects." ,
209
212
)
210
213
} else if (
@@ -215,11 +218,13 @@ function resolveStylesheet(options: ParserOptions, baseDir: string): string | nu
215
218
) {
216
219
console . error (
217
220
'stylesheet-is-preprocessor-file' ,
221
+ configPath ?? '' ,
218
222
'Your `tailwindStylesheet` option points to a preprocessor file. This is unsupported and you may get unexpected results.' ,
219
223
)
220
224
} else if ( ! options . tailwindStylesheet . endsWith ( '.css' ) ) {
221
225
console . error (
222
226
'stylesheet-is-not-css-file' ,
227
+ configPath ?? '' ,
223
228
'Your `tailwindStylesheet` option does not point to a CSS file. This is unsupported and you may get unexpected results.' ,
224
229
)
225
230
}
@@ -230,6 +235,7 @@ function resolveStylesheet(options: ParserOptions, baseDir: string): string | nu
230
235
if ( options . tailwindEntryPoint ) {
231
236
console . warn (
232
237
'entrypoint-is-deprecated' ,
238
+ configPath ?? '' ,
233
239
'Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindEntryPoint`.' ,
234
240
)
235
241
@@ -239,6 +245,7 @@ function resolveStylesheet(options: ParserOptions, baseDir: string): string | nu
239
245
if ( options . tailwindConfig && options . tailwindConfig . endsWith ( '.css' ) ) {
240
246
console . warn (
241
247
'config-as-css-is-deprecated' ,
248
+ configPath ?? '' ,
242
249
'Deprecated: Use the `tailwindStylesheet` option for v4 projects instead of `tailwindConfig`.' ,
243
250
)
244
251
0 commit comments