You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.8 KiB

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: ()=>resolveConfigPath
  8. });
  9. const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
  10. const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
  11. function _interopRequireDefault(obj) {
  12. return obj && obj.__esModule ? obj : {
  13. default: obj
  14. };
  15. }
  16. function isObject(value) {
  17. return typeof value === "object" && value !== null;
  18. }
  19. function isEmpty(obj) {
  20. return Object.keys(obj).length === 0;
  21. }
  22. function isString(value) {
  23. return typeof value === "string" || value instanceof String;
  24. }
  25. function resolveConfigPath(pathOrConfig) {
  26. // require('tailwindcss')({ theme: ..., variants: ... })
  27. if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
  28. return null;
  29. }
  30. // require('tailwindcss')({ config: 'custom-config.js' })
  31. if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isString(pathOrConfig.config)) {
  32. return _path.default.resolve(pathOrConfig.config);
  33. }
  34. // require('tailwindcss')({ config: { theme: ..., variants: ... } })
  35. if (isObject(pathOrConfig) && pathOrConfig.config !== undefined && isObject(pathOrConfig.config)) {
  36. return null;
  37. }
  38. // require('tailwindcss')('custom-config.js')
  39. if (isString(pathOrConfig)) {
  40. return _path.default.resolve(pathOrConfig);
  41. }
  42. // require('tailwindcss')
  43. for (const configFile of [
  44. "./tailwind.config.js",
  45. "./tailwind.config.cjs"
  46. ]){
  47. try {
  48. const configPath = _path.default.resolve(configFile);
  49. _fs.default.accessSync(configPath);
  50. return configPath;
  51. } catch (err) {}
  52. }
  53. return null;
  54. }