source: frontend/node_modules/tailwindcss/src/lib/load-config.ts

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.0 KB
Line 
1import jitiFactory from 'jiti'
2import { transform } from 'sucrase'
3
4import { Config } from '../../types/config'
5
6let jiti: ReturnType<typeof jitiFactory> | null = null
7
8// @internal
9// This WILL be removed in some future release
10// If you rely on this your stuff WILL break
11export function useCustomJiti(_jiti: () => ReturnType<typeof jitiFactory>) {
12 jiti = _jiti()
13}
14
15function lazyJiti() {
16 return (
17 jiti ??
18 (jiti = jitiFactory(__filename, {
19 interopDefault: true,
20 transform: (opts) => {
21 // Sucrase can't transform import.meta so we have to use Babel
22 if (opts.source.includes('import.meta')) {
23 return require('jiti/dist/babel.js')(opts)
24 }
25
26 return transform(opts.source, {
27 transforms: ['typescript', 'imports'],
28 })
29 },
30 }))
31 )
32}
33
34export function loadConfig(path: string): Config {
35 let config = (function () {
36 if (!path) return {}
37
38 try {
39 return require(path)
40 } catch {
41 return lazyJiti()(path)
42 }
43 })()
44
45 return config.default ?? config
46}
Note: See TracBrowser for help on using the repository browser.