| 1 | "use strict";
|
|---|
| 2 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 3 | value: true
|
|---|
| 4 | });
|
|---|
| 5 | function _export(target, all) {
|
|---|
| 6 | for(var name in all)Object.defineProperty(target, name, {
|
|---|
| 7 | enumerable: true,
|
|---|
| 8 | get: all[name]
|
|---|
| 9 | });
|
|---|
| 10 | }
|
|---|
| 11 | _export(exports, {
|
|---|
| 12 | default: function() {
|
|---|
| 13 | return resolveConfigPath;
|
|---|
| 14 | },
|
|---|
| 15 | resolveDefaultConfigPath: function() {
|
|---|
| 16 | return resolveDefaultConfigPath;
|
|---|
| 17 | }
|
|---|
| 18 | });
|
|---|
| 19 | const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|---|
| 20 | const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|---|
| 21 | function _interop_require_default(obj) {
|
|---|
| 22 | return obj && obj.__esModule ? obj : {
|
|---|
| 23 | default: obj
|
|---|
| 24 | };
|
|---|
| 25 | }
|
|---|
| 26 | const defaultConfigFiles = [
|
|---|
| 27 | "./tailwind.config.js",
|
|---|
| 28 | "./tailwind.config.cjs",
|
|---|
| 29 | "./tailwind.config.mjs",
|
|---|
| 30 | "./tailwind.config.ts",
|
|---|
| 31 | "./tailwind.config.cts",
|
|---|
| 32 | "./tailwind.config.mts"
|
|---|
| 33 | ];
|
|---|
| 34 | function isObject(value) {
|
|---|
| 35 | return typeof value === "object" && value !== null;
|
|---|
| 36 | }
|
|---|
| 37 | function isEmpty(obj) {
|
|---|
| 38 | return Object.keys(obj).length === 0;
|
|---|
| 39 | }
|
|---|
| 40 | function isString(value) {
|
|---|
| 41 | return typeof value === "string" || value instanceof String;
|
|---|
| 42 | }
|
|---|
| 43 | function resolveConfigPath(pathOrConfig) {
|
|---|
| 44 | // require('tailwindcss')({ theme: ..., variants: ... })
|
|---|
| 45 | if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
|
|---|
| 46 | return null;
|
|---|
| 47 | }
|
|---|
| 48 | // require('tailwindcss')({ config: 'custom-config.js' })
|
|---|
| 49 | if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isString(pathOrConfig.config)) {
|
|---|
| 50 | return _path.default.resolve(pathOrConfig.config);
|
|---|
| 51 | }
|
|---|
| 52 | // require('tailwindcss')({ config: { theme: ..., variants: ... } })
|
|---|
| 53 | if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isObject(pathOrConfig.config)) {
|
|---|
| 54 | return null;
|
|---|
| 55 | }
|
|---|
| 56 | // require('tailwindcss')('custom-config.js')
|
|---|
| 57 | if (isString(pathOrConfig)) {
|
|---|
| 58 | return _path.default.resolve(pathOrConfig);
|
|---|
| 59 | }
|
|---|
| 60 | // require('tailwindcss')
|
|---|
| 61 | return resolveDefaultConfigPath();
|
|---|
| 62 | }
|
|---|
| 63 | function resolveDefaultConfigPath() {
|
|---|
| 64 | for (const configFile of defaultConfigFiles){
|
|---|
| 65 | try {
|
|---|
| 66 | const configPath = _path.default.resolve(configFile);
|
|---|
| 67 | _fs.default.accessSync(configPath);
|
|---|
| 68 | return configPath;
|
|---|
| 69 | } catch (err) {}
|
|---|
| 70 | }
|
|---|
| 71 | return null;
|
|---|
| 72 | }
|
|---|