source: frontend/node_modules/tailwindcss/src/util/resolveConfigPath.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[9af201e]1import fs from 'fs'
2import path from 'path'
3
4const defaultConfigFiles = [
5 './tailwind.config.js',
6 './tailwind.config.cjs',
7 './tailwind.config.mjs',
8 './tailwind.config.ts',
9 './tailwind.config.cts',
10 './tailwind.config.mts',
11]
12
13function isObject(value) {
14 return typeof value === 'object' && value !== null
15}
16
17function isEmpty(obj) {
18 return Object.keys(obj).length === 0
19}
20
21function isString(value) {
22 return typeof value === 'string' || value instanceof String
23}
24
25export default function resolveConfigPath(pathOrConfig) {
26 // require('tailwindcss')({ theme: ..., variants: ... })
27 if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
28 return null
29 }
30
31 // require('tailwindcss')({ config: 'custom-config.js' })
32 if (
33 isObject(pathOrConfig) &&
34 pathOrConfig.config !== undefined &&
35 isString(pathOrConfig.config)
36 ) {
37 return path.resolve(pathOrConfig.config)
38 }
39
40 // require('tailwindcss')({ config: { theme: ..., variants: ... } })
41 if (
42 isObject(pathOrConfig) &&
43 pathOrConfig.config !== undefined &&
44 isObject(pathOrConfig.config)
45 ) {
46 return null
47 }
48
49 // require('tailwindcss')('custom-config.js')
50 if (isString(pathOrConfig)) {
51 return path.resolve(pathOrConfig)
52 }
53
54 // require('tailwindcss')
55 return resolveDefaultConfigPath()
56}
57
58export function resolveDefaultConfigPath() {
59 for (const configFile of defaultConfigFiles) {
60 try {
61 const configPath = path.resolve(configFile)
62 fs.accessSync(configPath)
63 return configPath
64 } catch (err) {}
65 }
66
67 return null
68}
Note: See TracBrowser for help on using the repository browser.