tailwindcss-config 2.0.0-next.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +9 -0
- package/README.md +5 -158
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.en.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# tailwindcss-config
|
|
2
|
+
|
|
3
|
+
> English | [简体中文](./README.md)
|
|
4
|
+
|
|
5
|
+
This package searches for and loads Tailwind CSS configuration files across JavaScript, TypeScript, ESM, and CommonJS formats.
|
|
6
|
+
|
|
7
|
+
## Website
|
|
8
|
+
|
|
9
|
+
For setup guides, configuration references, and framework examples, see the [official weapp-tailwindcss documentation](https://tw.icebreaker.top).
|
package/README.md
CHANGED
|
@@ -1,162 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tailwindcss-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 简体中文 | [English](./README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
这个包负责搜索和加载 Tailwind CSS 配置,支持 JavaScript、TypeScript、ESM 和 CommonJS 等多种配置文件格式。
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 官网
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **Automatic discovery**: Searches for configuration files in the current working directory or a specified path.
|
|
11
|
-
- **Graceful fallback**: Returns `undefined` if no configuration is found, ensuring compatibility with dynamic setups.
|
|
12
|
-
- **TypeScript support**: Fully typed for use in TypeScript projects.
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
Install the package via npm:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm i -D tailwindcss-config
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Or using Yarn:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
yarn add -D tailwindcss-config
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
### Import the Function
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { loadConfig } from 'tailwindcss-config'
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Examples
|
|
41
|
-
|
|
42
|
-
#### 1. Default Usage
|
|
43
|
-
|
|
44
|
-
The function searches for Tailwind CSS configuration files in the current working directory:
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
(async () => {
|
|
48
|
-
const config = await loadConfig()
|
|
49
|
-
console.log(config)
|
|
50
|
-
})()
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
#### 2. Specify a Configuration File
|
|
54
|
-
|
|
55
|
-
Explicitly specify a path to a Tailwind CSS configuration file:
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
(async () => {
|
|
59
|
-
const config = await loadConfig({ config: './tailwind.config.ts' })
|
|
60
|
-
console.log(config)
|
|
61
|
-
})()
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### 3. Change the Working Directory
|
|
65
|
-
|
|
66
|
-
Set a custom working directory to search for Tailwind configuration files:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
(async () => {
|
|
70
|
-
const config = await loadConfig({ cwd: '/my/project/directory' })
|
|
71
|
-
console.log(config)
|
|
72
|
-
})()
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Supported Configuration Formats
|
|
78
|
-
|
|
79
|
-
The utility supports the following file types:
|
|
80
|
-
|
|
81
|
-
- `tailwind.config.js`
|
|
82
|
-
- `tailwind.config.cjs`
|
|
83
|
-
- `tailwind.config.mjs`
|
|
84
|
-
- `tailwind.config.ts`
|
|
85
|
-
- `tailwind.config.cts`
|
|
86
|
-
- `tailwind.config.mts`
|
|
87
|
-
|
|
88
|
-
Dynamic imports are powered by [`jiti`](https://github.com/unjs/jiti), allowing the utility to handle various file types seamlessly.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## API Reference
|
|
93
|
-
|
|
94
|
-
### `loadConfig(options?: Partial<LoadConfigOptions>)`
|
|
95
|
-
|
|
96
|
-
#### Parameters
|
|
97
|
-
|
|
98
|
-
| Parameter | Type | Description | Default |
|
|
99
|
-
| ---------------- | ---------------------------- | ----------------------------------------------- | --------------- |
|
|
100
|
-
| `options` | `Partial<LoadConfigOptions>` | Options to customize configuration loading. | `{}` |
|
|
101
|
-
| `options.cwd` | `string` | Directory to search for configuration files. | `process.cwd()` |
|
|
102
|
-
| `options.config` | `string` | Path to a specific Tailwind configuration file. | `undefined` |
|
|
103
|
-
|
|
104
|
-
#### Returns
|
|
105
|
-
|
|
106
|
-
A `Promise` that resolves to a `Config` object or `undefined` if no configuration file is found.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## File Search Order
|
|
111
|
-
|
|
112
|
-
The utility uses [`lilconfig`](https://github.com/antonk52/lilconfig) to locate configuration files. It searches for the following files (in order):
|
|
113
|
-
|
|
114
|
-
1. `tailwind.config.js`
|
|
115
|
-
2. `tailwind.config.cjs`
|
|
116
|
-
3. `tailwind.config.mjs`
|
|
117
|
-
4. `tailwind.config.ts`
|
|
118
|
-
5. `tailwind.config.cts`
|
|
119
|
-
6. `tailwind.config.mts`
|
|
120
|
-
|
|
121
|
-
---
|
|
122
|
-
|
|
123
|
-
## Example Project Structure
|
|
124
|
-
|
|
125
|
-
```plaintext
|
|
126
|
-
my-project/
|
|
127
|
-
├── src/
|
|
128
|
-
│ └── index.ts
|
|
129
|
-
├── tailwind.config.ts
|
|
130
|
-
└── tailwind.config.js
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Loading Configuration
|
|
134
|
-
|
|
135
|
-
```typescript
|
|
136
|
-
(async () => {
|
|
137
|
-
const config = await loadConfig({ cwd: './my-project' })
|
|
138
|
-
console.log(config)
|
|
139
|
-
})()
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Error Handling
|
|
145
|
-
|
|
146
|
-
The `loadConfig` function does not throw an error if no configuration is found. Instead, it resolves to `undefined`. This ensures compatibility with projects where Tailwind configuration is optional or dynamically generated.
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Contributing
|
|
151
|
-
|
|
152
|
-
Contributions are welcome! To get started:
|
|
153
|
-
|
|
154
|
-
1. Fork this repository.
|
|
155
|
-
2. Create a new branch for your feature or bug fix.
|
|
156
|
-
3. Submit a pull request with a clear description of your changes.
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## License
|
|
161
|
-
|
|
162
|
-
This project is licensed under the [MIT License](../../LICENSE).
|
|
9
|
+
更多接入方式、配置说明和框架示例见 [weapp-tailwindcss 官方文档](https://tw.icebreaker.top)。
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createJiti } from "jiti";
|
|
|
5
5
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
6
6
|
//#region \0rolldown/runtime.js
|
|
7
7
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
8
|
-
var __require = /*
|
|
8
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/utils.ts
|
|
11
11
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "load tailwindcss config function",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"jiti": "2.7.0",
|
|
44
|
-
"@weapp-tailwindcss/shared": "2.0.0
|
|
44
|
+
"@weapp-tailwindcss/shared": "2.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"lilconfig": "^3.1.3"
|