tailwindcss-injector 0.0.0 → 0.0.2
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.md +112 -0
- package/dist/index.cjs +0 -43
- package/dist/index.d.cts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.js +0 -24
- package/dist/postcss.cjs +365 -13
- package/dist/postcss.d.cts +5 -3
- package/dist/postcss.d.ts +5 -3
- package/dist/postcss.js +361 -12
- package/package.json +6 -4
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# TailwindCSS Injector
|
|
2
|
+
|
|
3
|
+
**English | [中文](./README-cn.md)**
|
|
4
|
+
|
|
5
|
+
- [TailwindCSS Injector](#tailwindcss-injector)
|
|
6
|
+
- [Overview](#overview)
|
|
7
|
+
- [Features](#features)
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Usage](#usage)
|
|
10
|
+
- [Basic Example](#basic-example)
|
|
11
|
+
- [Options](#options)
|
|
12
|
+
- [Example Configuration](#example-configuration)
|
|
13
|
+
- [How It Works](#how-it-works)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
`tailwindcss-injector` is a library designed to dynamically inject TailwindCSS directives and configurations into your CSS workflow. It includes a PostCSS plugin that supports multiple file extensions, dynamic configuration, and flexible filtering, enabling seamless integration into modern build pipelines.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Dynamic Directive Injection**: Automatically inserts TailwindCSS directives like `@tailwind base`, `@tailwind components`, and `@tailwind utilities`.
|
|
27
|
+
- **Multi-extension Support**: Processes files with customizable extensions (e.g., `.html`, `.js`, `.ts`).
|
|
28
|
+
- **Inline or External Configuration**: Accepts inline configuration objects or paths to configuration files.
|
|
29
|
+
- **Customizable Filters**: Use a filter function to process specific files.
|
|
30
|
+
- **TailwindCSS Integration**: Dynamically adjusts TailwindCSS configurations per file.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install the package and its dependencies:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install tailwindcss-injector tailwindcss postcss --save-dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
To use the PostCSS plugin, import it from `tailwindcss-injector/postcss`:
|
|
47
|
+
|
|
48
|
+
### Basic Example
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
const tailwindInjector = require('tailwindcss-injector/postcss')
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
plugins: [
|
|
55
|
+
tailwindInjector({
|
|
56
|
+
cwd: process.cwd(),
|
|
57
|
+
config: './tailwind.config.js',
|
|
58
|
+
directiveParams: ['base', 'components', 'utilities'],
|
|
59
|
+
extensions: ['html', 'js', 'ts'],
|
|
60
|
+
filter: input => !!input?.file && input.file.endsWith('.css'),
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Options
|
|
69
|
+
|
|
70
|
+
The plugin accepts the following options:
|
|
71
|
+
|
|
72
|
+
| Option | Type | Description |
|
|
73
|
+
| ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------- |
|
|
74
|
+
| `cwd` | `string` | Current working directory. |
|
|
75
|
+
| `config` | `string \| Partial<Config> \| (input) => InlineTailwindcssOptions` | TailwindCSS configuration file path or inline configuration object. |
|
|
76
|
+
| `directiveParams` | `('base' \| 'components' \| 'utilities' \| 'variants')[]` | Array of TailwindCSS directives to inject. |
|
|
77
|
+
| `extensions` | `string[]` | Array of supported file extensions. |
|
|
78
|
+
| `filter` | `(input?: postcss.Input) => boolean` | Custom function to filter files to process. |
|
|
79
|
+
|
|
80
|
+
### Example Configuration
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
{
|
|
84
|
+
cwd: process.cwd(), // Set current working directory
|
|
85
|
+
config: './tailwind.config.js', // Use an external TailwindCSS configuration file
|
|
86
|
+
directiveParams: ['base', 'components', 'utilities'], // Inject directives dynamically
|
|
87
|
+
extensions: ['html', 'js', 'ts'], // Process specific file extensions
|
|
88
|
+
filter: (input) => !!input?.file && input.file.endsWith('.css'), // Filter for CSS files only
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## How It Works
|
|
95
|
+
|
|
96
|
+
1. **Directive Injection**:
|
|
97
|
+
The plugin ensures that the specified TailwindCSS directives (`@tailwind base`, `@tailwind components`, etc.) are injected into the CSS files.
|
|
98
|
+
|
|
99
|
+
2. **Dynamic Configuration**:
|
|
100
|
+
TailwindCSS configurations are dynamically adjusted based on the processed files, including custom extensions.
|
|
101
|
+
|
|
102
|
+
3. **File Filtering**:
|
|
103
|
+
Files to process can be filtered using the `filter` option.
|
|
104
|
+
|
|
105
|
+
4. **PostCSS Processing**:
|
|
106
|
+
The plugin integrates with PostCSS to apply TailwindCSS transformations seamlessly.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
This project is licensed under the **MIT License**. See the `LICENSE` file for details.
|
package/dist/index.cjs
CHANGED
|
@@ -1,44 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
bar: () => bar,
|
|
24
|
-
getDirname: () => getDirname,
|
|
25
|
-
xx: () => xx
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
28
|
-
function bar() {
|
|
29
|
-
return "foo";
|
|
30
|
-
}
|
|
31
|
-
function getDirname() {
|
|
32
|
-
return __dirname;
|
|
33
|
-
}
|
|
34
|
-
var xx = /* @__PURE__ */ ((xx2) => {
|
|
35
|
-
xx2[xx2["id"] = 0] = "id";
|
|
36
|
-
xx2[xx2["dd"] = 1] = "dd";
|
|
37
|
-
return xx2;
|
|
38
|
-
})(xx || {});
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
bar,
|
|
42
|
-
getDirname,
|
|
43
|
-
xx
|
|
44
|
-
});
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
|
-
import path from "path";
|
|
4
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
5
|
-
var getDirname = () => path.dirname(getFilename());
|
|
6
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
|
-
|
|
8
|
-
// src/index.ts
|
|
9
|
-
function bar() {
|
|
10
|
-
return "foo";
|
|
11
|
-
}
|
|
12
|
-
function getDirname2() {
|
|
13
|
-
return __dirname;
|
|
14
|
-
}
|
|
15
|
-
var xx = /* @__PURE__ */ ((xx2) => {
|
|
16
|
-
xx2[xx2["id"] = 0] = "id";
|
|
17
|
-
xx2[xx2["dd"] = 1] = "dd";
|
|
18
|
-
return xx2;
|
|
19
|
-
})(xx || {});
|
|
20
|
-
export {
|
|
21
|
-
bar,
|
|
22
|
-
getDirname2 as getDirname,
|
|
23
|
-
xx
|
|
24
|
-
};
|
package/dist/postcss.cjs
CHANGED
|
@@ -1,4 +1,241 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.1_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
|
|
31
|
+
var getImportMetaUrl, importMetaUrl;
|
|
32
|
+
var init_cjs_shims = __esm({
|
|
33
|
+
"../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.1_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
|
|
34
|
+
"use strict";
|
|
35
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
36
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
|
|
41
|
+
var require_is_primitive = __commonJS({
|
|
42
|
+
"../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
|
|
43
|
+
"use strict";
|
|
44
|
+
init_cjs_shims();
|
|
45
|
+
module.exports = function isPrimitive(val) {
|
|
46
|
+
if (typeof val === "object") {
|
|
47
|
+
return val === null;
|
|
48
|
+
}
|
|
49
|
+
return typeof val !== "function";
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
|
|
55
|
+
var require_isobject = __commonJS({
|
|
56
|
+
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
|
|
57
|
+
"use strict";
|
|
58
|
+
init_cjs_shims();
|
|
59
|
+
module.exports = function isObject(val) {
|
|
60
|
+
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
66
|
+
var require_is_plain_object = __commonJS({
|
|
67
|
+
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
|
|
68
|
+
"use strict";
|
|
69
|
+
init_cjs_shims();
|
|
70
|
+
var isObject = require_isobject();
|
|
71
|
+
function isObjectObject(o) {
|
|
72
|
+
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
73
|
+
}
|
|
74
|
+
module.exports = function isPlainObject2(o) {
|
|
75
|
+
var ctor, prot;
|
|
76
|
+
if (isObjectObject(o) === false) return false;
|
|
77
|
+
ctor = o.constructor;
|
|
78
|
+
if (typeof ctor !== "function") return false;
|
|
79
|
+
prot = ctor.prototype;
|
|
80
|
+
if (isObjectObject(prot) === false) return false;
|
|
81
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
|
|
90
|
+
var require_set_value = __commonJS({
|
|
91
|
+
"../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
|
|
92
|
+
"use strict";
|
|
93
|
+
init_cjs_shims();
|
|
94
|
+
var { deleteProperty } = Reflect;
|
|
95
|
+
var isPrimitive = require_is_primitive();
|
|
96
|
+
var isPlainObject2 = require_is_plain_object();
|
|
97
|
+
var isObject = (value) => {
|
|
98
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
99
|
+
};
|
|
100
|
+
var isUnsafeKey = (key) => {
|
|
101
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
102
|
+
};
|
|
103
|
+
var validateKey = (key) => {
|
|
104
|
+
if (!isPrimitive(key)) {
|
|
105
|
+
throw new TypeError("Object keys must be strings or symbols");
|
|
106
|
+
}
|
|
107
|
+
if (isUnsafeKey(key)) {
|
|
108
|
+
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var toStringKey = (input) => {
|
|
112
|
+
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
113
|
+
};
|
|
114
|
+
var createMemoKey = (input, options) => {
|
|
115
|
+
if (typeof input !== "string" || !options) return input;
|
|
116
|
+
let key = input + ";";
|
|
117
|
+
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
118
|
+
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
119
|
+
if (options.split !== void 0) key += `split=${options.split};`;
|
|
120
|
+
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
121
|
+
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
122
|
+
return key;
|
|
123
|
+
};
|
|
124
|
+
var memoize = (input, options, fn) => {
|
|
125
|
+
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
126
|
+
validateKey(key);
|
|
127
|
+
const value = setValue.cache.get(key) || fn();
|
|
128
|
+
setValue.cache.set(key, value);
|
|
129
|
+
return value;
|
|
130
|
+
};
|
|
131
|
+
var splitString = (input, options = {}) => {
|
|
132
|
+
const sep = options.separator || ".";
|
|
133
|
+
const preserve = sep === "/" ? false : options.preservePaths;
|
|
134
|
+
if (typeof input === "string" && preserve !== false && /\//.test(input)) {
|
|
135
|
+
return [input];
|
|
136
|
+
}
|
|
137
|
+
const parts = [];
|
|
138
|
+
let part = "";
|
|
139
|
+
const push = (part2) => {
|
|
140
|
+
let number;
|
|
141
|
+
if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
|
|
142
|
+
parts.push(number);
|
|
143
|
+
} else {
|
|
144
|
+
parts.push(part2);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
for (let i = 0; i < input.length; i++) {
|
|
148
|
+
const value = input[i];
|
|
149
|
+
if (value === "\\") {
|
|
150
|
+
part += input[++i];
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (value === sep) {
|
|
154
|
+
push(part);
|
|
155
|
+
part = "";
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
part += value;
|
|
159
|
+
}
|
|
160
|
+
if (part) {
|
|
161
|
+
push(part);
|
|
162
|
+
}
|
|
163
|
+
return parts;
|
|
164
|
+
};
|
|
165
|
+
var split = (input, options) => {
|
|
166
|
+
if (options && typeof options.split === "function") return options.split(input);
|
|
167
|
+
if (typeof input === "symbol") return [input];
|
|
168
|
+
if (Array.isArray(input)) return input;
|
|
169
|
+
return memoize(input, options, () => splitString(input, options));
|
|
170
|
+
};
|
|
171
|
+
var assignProp = (obj, prop, value, options) => {
|
|
172
|
+
validateKey(prop);
|
|
173
|
+
if (value === void 0) {
|
|
174
|
+
deleteProperty(obj, prop);
|
|
175
|
+
} else if (options && options.merge) {
|
|
176
|
+
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
177
|
+
if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
|
|
178
|
+
obj[prop] = merge(obj[prop], value);
|
|
179
|
+
} else {
|
|
180
|
+
obj[prop] = value;
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
obj[prop] = value;
|
|
184
|
+
}
|
|
185
|
+
return obj;
|
|
186
|
+
};
|
|
187
|
+
var setValue = (target, path3, value, options) => {
|
|
188
|
+
if (!path3 || !isObject(target)) return target;
|
|
189
|
+
const keys = split(path3, options);
|
|
190
|
+
let obj = target;
|
|
191
|
+
for (let i = 0; i < keys.length; i++) {
|
|
192
|
+
const key = keys[i];
|
|
193
|
+
const next = keys[i + 1];
|
|
194
|
+
validateKey(key);
|
|
195
|
+
if (next === void 0) {
|
|
196
|
+
assignProp(obj, key, value, options);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
200
|
+
obj = obj[key] = [];
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (!isObject(obj[key])) {
|
|
204
|
+
obj[key] = {};
|
|
205
|
+
}
|
|
206
|
+
obj = obj[key];
|
|
207
|
+
}
|
|
208
|
+
return target;
|
|
209
|
+
};
|
|
210
|
+
setValue.split = split;
|
|
211
|
+
setValue.cache = /* @__PURE__ */ new Map();
|
|
212
|
+
setValue.clear = () => {
|
|
213
|
+
setValue.cache = /* @__PURE__ */ new Map();
|
|
214
|
+
};
|
|
215
|
+
module.exports = setValue;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// src/postcss.ts
|
|
220
|
+
init_cjs_shims();
|
|
221
|
+
var import_set_value = __toESM(require_set_value(), 1);
|
|
222
|
+
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
223
|
+
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
224
|
+
var _tailwindcss = require('tailwindcss'); var _tailwindcss2 = _interopRequireDefault(_tailwindcss);
|
|
225
|
+
|
|
226
|
+
// src/config.ts
|
|
227
|
+
init_cjs_shims();
|
|
228
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
229
|
+
|
|
230
|
+
var _jiti = require('jiti');
|
|
231
|
+
var _lilconfig = require('lilconfig');
|
|
232
|
+
|
|
233
|
+
// src/utils.ts
|
|
234
|
+
init_cjs_shims();
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
238
|
+
init_cjs_shims();
|
|
2
239
|
function isPlainObject(value) {
|
|
3
240
|
if (value === null || typeof value !== "object") {
|
|
4
241
|
return false;
|
|
@@ -66,25 +303,106 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
66
303
|
}
|
|
67
304
|
});
|
|
68
305
|
|
|
306
|
+
// src/utils.ts
|
|
307
|
+
function removeFileExtension(filePath) {
|
|
308
|
+
let baseName = _path2.default.basename(filePath, _path2.default.extname(filePath));
|
|
309
|
+
while (baseName.includes(".")) {
|
|
310
|
+
baseName = _path2.default.basename(baseName, _path2.default.extname(baseName));
|
|
311
|
+
}
|
|
312
|
+
const dir = _path2.default.dirname(filePath);
|
|
313
|
+
return _path2.default.join(dir, baseName);
|
|
314
|
+
}
|
|
315
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
316
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
317
|
+
obj[key] = value;
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// src/config.ts
|
|
323
|
+
var jiti = _jiti.createJiti.call(void 0, importMetaUrl);
|
|
324
|
+
var moduleName = "tailwind";
|
|
325
|
+
async function loadConfig(options) {
|
|
326
|
+
const { config, cwd } = defuOverrideArray(options, {
|
|
327
|
+
cwd: _process2.default.cwd()
|
|
328
|
+
});
|
|
329
|
+
const searcher = _lilconfig.lilconfig.call(void 0, "tailwindcss", {
|
|
330
|
+
searchPlaces: [
|
|
331
|
+
`${moduleName}.config.js`,
|
|
332
|
+
`${moduleName}.config.cjs`,
|
|
333
|
+
`${moduleName}.config.mjs`,
|
|
334
|
+
`${moduleName}.config.ts`,
|
|
335
|
+
`${moduleName}.config.cts`,
|
|
336
|
+
`${moduleName}.config.mts`
|
|
337
|
+
],
|
|
338
|
+
loaders: {
|
|
339
|
+
".js": jiti,
|
|
340
|
+
".cjs": jiti,
|
|
341
|
+
".mjs": jiti,
|
|
342
|
+
".ts": jiti,
|
|
343
|
+
".cts": jiti,
|
|
344
|
+
".mts": jiti
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
if (typeof config === "string" && config) {
|
|
348
|
+
const configPath = _path2.default.isAbsolute(config) ? config : _path2.default.resolve(cwd, config);
|
|
349
|
+
const result = await searcher.load(configPath);
|
|
350
|
+
return _optionalChain([result, 'optionalAccess', _ => _.config]);
|
|
351
|
+
} else {
|
|
352
|
+
const result = await searcher.search(cwd);
|
|
353
|
+
return _optionalChain([result, 'optionalAccess', _2 => _2.config]);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
69
357
|
// src/postcss.ts
|
|
70
|
-
var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
|
|
71
|
-
var _tailwindcss = require('tailwindcss'); var _tailwindcss2 = _interopRequireDefault(_tailwindcss);
|
|
72
358
|
var creator = (options) => {
|
|
73
|
-
const { config, filter } =
|
|
359
|
+
const { config, filter, directiveParams, cwd, extensions } = defuOverrideArray(options, {
|
|
74
360
|
filter: () => true,
|
|
75
|
-
config: void 0
|
|
361
|
+
config: void 0,
|
|
362
|
+
directiveParams: ["utilities", "components"],
|
|
363
|
+
cwd: _process2.default.cwd(),
|
|
364
|
+
extensions: ["wxml", "js", "ts"]
|
|
76
365
|
});
|
|
366
|
+
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
77
367
|
return {
|
|
78
368
|
postcssPlugin: "postcss-tailwindcss-injector",
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
369
|
+
plugins: [
|
|
370
|
+
{
|
|
371
|
+
postcssPlugin: "post",
|
|
372
|
+
async Once(root, helpers) {
|
|
373
|
+
if (filter(_optionalChain([root, 'access', _3 => _3.source, 'optionalAccess', _4 => _4.input]))) {
|
|
374
|
+
let _root = root;
|
|
375
|
+
for (const params of directiveParams) {
|
|
376
|
+
const node = root.nodes.find((x) => x.type === "atrule" && x.params === params);
|
|
377
|
+
if (!node) {
|
|
378
|
+
_root = _root.prepend(helpers.atRule({ name: "tailwind", params }));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const cfg = typeof config === "function" ? config(_optionalChain([root, 'access', _5 => _5.source, 'optionalAccess', _6 => _6.input])) : config;
|
|
382
|
+
let tailwindcssConfig;
|
|
383
|
+
if (typeof cfg === "string") {
|
|
384
|
+
tailwindcssConfig = await loadConfig({
|
|
385
|
+
cwd,
|
|
386
|
+
config: cfg
|
|
387
|
+
});
|
|
388
|
+
} else {
|
|
389
|
+
tailwindcssConfig = _nullishCoalesce(cfg, () => ( {
|
|
390
|
+
content: []
|
|
391
|
+
}));
|
|
392
|
+
}
|
|
393
|
+
if (tailwindcssConfig && _optionalChain([root, 'access', _7 => _7.source, 'optionalAccess', _8 => _8.input]) && root.source.input.file) {
|
|
394
|
+
(0, import_set_value.default)(tailwindcssConfig, "content", [
|
|
395
|
+
`${removeFileExtension(root.source.input.file)}.${extensionsGlob}`
|
|
396
|
+
]);
|
|
397
|
+
}
|
|
398
|
+
const { root: newRoot } = await _postcss2.default.call(void 0, [
|
|
399
|
+
_tailwindcss2.default.call(void 0, tailwindcssConfig)
|
|
400
|
+
]).process(_root);
|
|
401
|
+
root.replaceWith(newRoot);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
86
404
|
}
|
|
87
|
-
|
|
405
|
+
]
|
|
88
406
|
};
|
|
89
407
|
};
|
|
90
408
|
creator.postcss = true;
|
|
@@ -92,5 +410,39 @@ var postcss_default = creator;
|
|
|
92
410
|
|
|
93
411
|
|
|
94
412
|
exports.default = postcss_default;
|
|
413
|
+
/*! Bundled license information:
|
|
414
|
+
|
|
415
|
+
is-primitive/index.js:
|
|
416
|
+
(*!
|
|
417
|
+
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
|
418
|
+
*
|
|
419
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
420
|
+
* Released under the MIT License.
|
|
421
|
+
*)
|
|
422
|
+
|
|
423
|
+
isobject/index.js:
|
|
424
|
+
(*!
|
|
425
|
+
* isobject <https://github.com/jonschlinkert/isobject>
|
|
426
|
+
*
|
|
427
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
428
|
+
* Released under the MIT License.
|
|
429
|
+
*)
|
|
430
|
+
|
|
431
|
+
is-plain-object/index.js:
|
|
432
|
+
(*!
|
|
433
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
434
|
+
*
|
|
435
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
436
|
+
* Released under the MIT License.
|
|
437
|
+
*)
|
|
438
|
+
|
|
439
|
+
set-value/index.js:
|
|
440
|
+
(*!
|
|
441
|
+
* set-value <https://github.com/jonschlinkert/set-value>
|
|
442
|
+
*
|
|
443
|
+
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
444
|
+
* Released under the MIT License.
|
|
445
|
+
*)
|
|
446
|
+
*/
|
|
95
447
|
|
|
96
448
|
module.exports = exports.default;
|
package/dist/postcss.d.cts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import postcss, { PluginCreator } from 'postcss';
|
|
2
2
|
import { Config } from 'tailwindcss';
|
|
3
3
|
|
|
4
|
-
type InlineTailwindcssOptions = string | Config |
|
|
5
|
-
config: string | Config;
|
|
6
|
-
} | undefined;
|
|
4
|
+
type InlineTailwindcssOptions = string | Partial<Config> | undefined;
|
|
7
5
|
interface Options {
|
|
6
|
+
cwd: string;
|
|
8
7
|
filter: (input?: postcss.Input) => boolean;
|
|
9
8
|
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
9
|
+
directiveParams: ('base' | 'components' | 'utilities' | 'variants')[];
|
|
10
|
+
extensions: string[];
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
declare const creator: PluginCreator<Partial<Options>>;
|
|
12
14
|
|
|
13
15
|
export { type Options, creator as default };
|
package/dist/postcss.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import postcss, { PluginCreator } from 'postcss';
|
|
2
2
|
import { Config } from 'tailwindcss';
|
|
3
3
|
|
|
4
|
-
type InlineTailwindcssOptions = string | Config |
|
|
5
|
-
config: string | Config;
|
|
6
|
-
} | undefined;
|
|
4
|
+
type InlineTailwindcssOptions = string | Partial<Config> | undefined;
|
|
7
5
|
interface Options {
|
|
6
|
+
cwd: string;
|
|
8
7
|
filter: (input?: postcss.Input) => boolean;
|
|
9
8
|
config: InlineTailwindcssOptions | ((input?: postcss.Input) => InlineTailwindcssOptions);
|
|
9
|
+
directiveParams: ('base' | 'components' | 'utilities' | 'variants')[];
|
|
10
|
+
extensions: string[];
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
declare const creator: PluginCreator<Partial<Options>>;
|
|
12
14
|
|
|
13
15
|
export { type Options, creator as default };
|
package/dist/postcss.js
CHANGED
|
@@ -1,4 +1,238 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.1_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
var init_esm_shims = __esm({
|
|
32
|
+
"../../node_modules/.pnpm/tsup@8.3.5_jiti@2.4.1_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js"() {
|
|
33
|
+
"use strict";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
|
|
38
|
+
var require_is_primitive = __commonJS({
|
|
39
|
+
"../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js"(exports, module) {
|
|
40
|
+
"use strict";
|
|
41
|
+
init_esm_shims();
|
|
42
|
+
module.exports = function isPrimitive(val) {
|
|
43
|
+
if (typeof val === "object") {
|
|
44
|
+
return val === null;
|
|
45
|
+
}
|
|
46
|
+
return typeof val !== "function";
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
|
|
52
|
+
var require_isobject = __commonJS({
|
|
53
|
+
"../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
|
|
54
|
+
"use strict";
|
|
55
|
+
init_esm_shims();
|
|
56
|
+
module.exports = function isObject(val) {
|
|
57
|
+
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
|
|
63
|
+
var require_is_plain_object = __commonJS({
|
|
64
|
+
"../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js"(exports, module) {
|
|
65
|
+
"use strict";
|
|
66
|
+
init_esm_shims();
|
|
67
|
+
var isObject = require_isobject();
|
|
68
|
+
function isObjectObject(o) {
|
|
69
|
+
return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
|
|
70
|
+
}
|
|
71
|
+
module.exports = function isPlainObject2(o) {
|
|
72
|
+
var ctor, prot;
|
|
73
|
+
if (isObjectObject(o) === false) return false;
|
|
74
|
+
ctor = o.constructor;
|
|
75
|
+
if (typeof ctor !== "function") return false;
|
|
76
|
+
prot = ctor.prototype;
|
|
77
|
+
if (isObjectObject(prot) === false) return false;
|
|
78
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
|
|
87
|
+
var require_set_value = __commonJS({
|
|
88
|
+
"../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js"(exports, module) {
|
|
89
|
+
"use strict";
|
|
90
|
+
init_esm_shims();
|
|
91
|
+
var { deleteProperty } = Reflect;
|
|
92
|
+
var isPrimitive = require_is_primitive();
|
|
93
|
+
var isPlainObject2 = require_is_plain_object();
|
|
94
|
+
var isObject = (value) => {
|
|
95
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
96
|
+
};
|
|
97
|
+
var isUnsafeKey = (key) => {
|
|
98
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
99
|
+
};
|
|
100
|
+
var validateKey = (key) => {
|
|
101
|
+
if (!isPrimitive(key)) {
|
|
102
|
+
throw new TypeError("Object keys must be strings or symbols");
|
|
103
|
+
}
|
|
104
|
+
if (isUnsafeKey(key)) {
|
|
105
|
+
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var toStringKey = (input) => {
|
|
109
|
+
return Array.isArray(input) ? input.flat().map(String).join(",") : input;
|
|
110
|
+
};
|
|
111
|
+
var createMemoKey = (input, options) => {
|
|
112
|
+
if (typeof input !== "string" || !options) return input;
|
|
113
|
+
let key = input + ";";
|
|
114
|
+
if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
|
|
115
|
+
if (options.separator !== void 0) key += `separator=${options.separator};`;
|
|
116
|
+
if (options.split !== void 0) key += `split=${options.split};`;
|
|
117
|
+
if (options.merge !== void 0) key += `merge=${options.merge};`;
|
|
118
|
+
if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
|
|
119
|
+
return key;
|
|
120
|
+
};
|
|
121
|
+
var memoize = (input, options, fn) => {
|
|
122
|
+
const key = toStringKey(options ? createMemoKey(input, options) : input);
|
|
123
|
+
validateKey(key);
|
|
124
|
+
const value = setValue.cache.get(key) || fn();
|
|
125
|
+
setValue.cache.set(key, value);
|
|
126
|
+
return value;
|
|
127
|
+
};
|
|
128
|
+
var splitString = (input, options = {}) => {
|
|
129
|
+
const sep = options.separator || ".";
|
|
130
|
+
const preserve = sep === "/" ? false : options.preservePaths;
|
|
131
|
+
if (typeof input === "string" && preserve !== false && /\//.test(input)) {
|
|
132
|
+
return [input];
|
|
133
|
+
}
|
|
134
|
+
const parts = [];
|
|
135
|
+
let part = "";
|
|
136
|
+
const push = (part2) => {
|
|
137
|
+
let number;
|
|
138
|
+
if (part2.trim() !== "" && Number.isInteger(number = Number(part2))) {
|
|
139
|
+
parts.push(number);
|
|
140
|
+
} else {
|
|
141
|
+
parts.push(part2);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
for (let i = 0; i < input.length; i++) {
|
|
145
|
+
const value = input[i];
|
|
146
|
+
if (value === "\\") {
|
|
147
|
+
part += input[++i];
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (value === sep) {
|
|
151
|
+
push(part);
|
|
152
|
+
part = "";
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
part += value;
|
|
156
|
+
}
|
|
157
|
+
if (part) {
|
|
158
|
+
push(part);
|
|
159
|
+
}
|
|
160
|
+
return parts;
|
|
161
|
+
};
|
|
162
|
+
var split = (input, options) => {
|
|
163
|
+
if (options && typeof options.split === "function") return options.split(input);
|
|
164
|
+
if (typeof input === "symbol") return [input];
|
|
165
|
+
if (Array.isArray(input)) return input;
|
|
166
|
+
return memoize(input, options, () => splitString(input, options));
|
|
167
|
+
};
|
|
168
|
+
var assignProp = (obj, prop, value, options) => {
|
|
169
|
+
validateKey(prop);
|
|
170
|
+
if (value === void 0) {
|
|
171
|
+
deleteProperty(obj, prop);
|
|
172
|
+
} else if (options && options.merge) {
|
|
173
|
+
const merge = options.merge === "function" ? options.merge : Object.assign;
|
|
174
|
+
if (merge && isPlainObject2(obj[prop]) && isPlainObject2(value)) {
|
|
175
|
+
obj[prop] = merge(obj[prop], value);
|
|
176
|
+
} else {
|
|
177
|
+
obj[prop] = value;
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
obj[prop] = value;
|
|
181
|
+
}
|
|
182
|
+
return obj;
|
|
183
|
+
};
|
|
184
|
+
var setValue = (target, path3, value, options) => {
|
|
185
|
+
if (!path3 || !isObject(target)) return target;
|
|
186
|
+
const keys = split(path3, options);
|
|
187
|
+
let obj = target;
|
|
188
|
+
for (let i = 0; i < keys.length; i++) {
|
|
189
|
+
const key = keys[i];
|
|
190
|
+
const next = keys[i + 1];
|
|
191
|
+
validateKey(key);
|
|
192
|
+
if (next === void 0) {
|
|
193
|
+
assignProp(obj, key, value, options);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (typeof next === "number" && !Array.isArray(obj[key])) {
|
|
197
|
+
obj = obj[key] = [];
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (!isObject(obj[key])) {
|
|
201
|
+
obj[key] = {};
|
|
202
|
+
}
|
|
203
|
+
obj = obj[key];
|
|
204
|
+
}
|
|
205
|
+
return target;
|
|
206
|
+
};
|
|
207
|
+
setValue.split = split;
|
|
208
|
+
setValue.cache = /* @__PURE__ */ new Map();
|
|
209
|
+
setValue.clear = () => {
|
|
210
|
+
setValue.cache = /* @__PURE__ */ new Map();
|
|
211
|
+
};
|
|
212
|
+
module.exports = setValue;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// src/postcss.ts
|
|
217
|
+
init_esm_shims();
|
|
218
|
+
var import_set_value = __toESM(require_set_value(), 1);
|
|
219
|
+
import process2 from "node:process";
|
|
220
|
+
import postcss from "postcss";
|
|
221
|
+
import tailwindcss from "tailwindcss";
|
|
222
|
+
|
|
223
|
+
// src/config.ts
|
|
224
|
+
init_esm_shims();
|
|
225
|
+
import path2 from "node:path";
|
|
226
|
+
import process from "node:process";
|
|
227
|
+
import { createJiti } from "jiti";
|
|
228
|
+
import { lilconfig } from "lilconfig";
|
|
229
|
+
|
|
230
|
+
// src/utils.ts
|
|
231
|
+
init_esm_shims();
|
|
232
|
+
import path from "node:path";
|
|
233
|
+
|
|
1
234
|
// ../../node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs
|
|
235
|
+
init_esm_shims();
|
|
2
236
|
function isPlainObject(value) {
|
|
3
237
|
if (value === null || typeof value !== "object") {
|
|
4
238
|
return false;
|
|
@@ -66,25 +300,106 @@ var defuArrayFn = createDefu((object, key, currentValue) => {
|
|
|
66
300
|
}
|
|
67
301
|
});
|
|
68
302
|
|
|
303
|
+
// src/utils.ts
|
|
304
|
+
function removeFileExtension(filePath) {
|
|
305
|
+
let baseName = path.basename(filePath, path.extname(filePath));
|
|
306
|
+
while (baseName.includes(".")) {
|
|
307
|
+
baseName = path.basename(baseName, path.extname(baseName));
|
|
308
|
+
}
|
|
309
|
+
const dir = path.dirname(filePath);
|
|
310
|
+
return path.join(dir, baseName);
|
|
311
|
+
}
|
|
312
|
+
var defuOverrideArray = createDefu((obj, key, value) => {
|
|
313
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
314
|
+
obj[key] = value;
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// src/config.ts
|
|
320
|
+
var jiti = createJiti(import.meta.url);
|
|
321
|
+
var moduleName = "tailwind";
|
|
322
|
+
async function loadConfig(options) {
|
|
323
|
+
const { config, cwd } = defuOverrideArray(options, {
|
|
324
|
+
cwd: process.cwd()
|
|
325
|
+
});
|
|
326
|
+
const searcher = lilconfig("tailwindcss", {
|
|
327
|
+
searchPlaces: [
|
|
328
|
+
`${moduleName}.config.js`,
|
|
329
|
+
`${moduleName}.config.cjs`,
|
|
330
|
+
`${moduleName}.config.mjs`,
|
|
331
|
+
`${moduleName}.config.ts`,
|
|
332
|
+
`${moduleName}.config.cts`,
|
|
333
|
+
`${moduleName}.config.mts`
|
|
334
|
+
],
|
|
335
|
+
loaders: {
|
|
336
|
+
".js": jiti,
|
|
337
|
+
".cjs": jiti,
|
|
338
|
+
".mjs": jiti,
|
|
339
|
+
".ts": jiti,
|
|
340
|
+
".cts": jiti,
|
|
341
|
+
".mts": jiti
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
if (typeof config === "string" && config) {
|
|
345
|
+
const configPath = path2.isAbsolute(config) ? config : path2.resolve(cwd, config);
|
|
346
|
+
const result = await searcher.load(configPath);
|
|
347
|
+
return result?.config;
|
|
348
|
+
} else {
|
|
349
|
+
const result = await searcher.search(cwd);
|
|
350
|
+
return result?.config;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
69
354
|
// src/postcss.ts
|
|
70
|
-
import postcss from "postcss";
|
|
71
|
-
import tailwindcss from "tailwindcss";
|
|
72
355
|
var creator = (options) => {
|
|
73
|
-
const { config, filter } =
|
|
356
|
+
const { config, filter, directiveParams, cwd, extensions } = defuOverrideArray(options, {
|
|
74
357
|
filter: () => true,
|
|
75
|
-
config: void 0
|
|
358
|
+
config: void 0,
|
|
359
|
+
directiveParams: ["utilities", "components"],
|
|
360
|
+
cwd: process2.cwd(),
|
|
361
|
+
extensions: ["wxml", "js", "ts"]
|
|
76
362
|
});
|
|
363
|
+
const extensionsGlob = `{${extensions.join(",")}}`;
|
|
77
364
|
return {
|
|
78
365
|
postcssPlugin: "postcss-tailwindcss-injector",
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
366
|
+
plugins: [
|
|
367
|
+
{
|
|
368
|
+
postcssPlugin: "post",
|
|
369
|
+
async Once(root, helpers) {
|
|
370
|
+
if (filter(root.source?.input)) {
|
|
371
|
+
let _root = root;
|
|
372
|
+
for (const params of directiveParams) {
|
|
373
|
+
const node = root.nodes.find((x) => x.type === "atrule" && x.params === params);
|
|
374
|
+
if (!node) {
|
|
375
|
+
_root = _root.prepend(helpers.atRule({ name: "tailwind", params }));
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const cfg = typeof config === "function" ? config(root.source?.input) : config;
|
|
379
|
+
let tailwindcssConfig;
|
|
380
|
+
if (typeof cfg === "string") {
|
|
381
|
+
tailwindcssConfig = await loadConfig({
|
|
382
|
+
cwd,
|
|
383
|
+
config: cfg
|
|
384
|
+
});
|
|
385
|
+
} else {
|
|
386
|
+
tailwindcssConfig = cfg ?? {
|
|
387
|
+
content: []
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
if (tailwindcssConfig && root.source?.input && root.source.input.file) {
|
|
391
|
+
(0, import_set_value.default)(tailwindcssConfig, "content", [
|
|
392
|
+
`${removeFileExtension(root.source.input.file)}.${extensionsGlob}`
|
|
393
|
+
]);
|
|
394
|
+
}
|
|
395
|
+
const { root: newRoot } = await postcss([
|
|
396
|
+
tailwindcss(tailwindcssConfig)
|
|
397
|
+
]).process(_root);
|
|
398
|
+
root.replaceWith(newRoot);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
86
401
|
}
|
|
87
|
-
|
|
402
|
+
]
|
|
88
403
|
};
|
|
89
404
|
};
|
|
90
405
|
creator.postcss = true;
|
|
@@ -92,3 +407,37 @@ var postcss_default = creator;
|
|
|
92
407
|
export {
|
|
93
408
|
postcss_default as default
|
|
94
409
|
};
|
|
410
|
+
/*! Bundled license information:
|
|
411
|
+
|
|
412
|
+
is-primitive/index.js:
|
|
413
|
+
(*!
|
|
414
|
+
* is-primitive <https://github.com/jonschlinkert/is-primitive>
|
|
415
|
+
*
|
|
416
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
417
|
+
* Released under the MIT License.
|
|
418
|
+
*)
|
|
419
|
+
|
|
420
|
+
isobject/index.js:
|
|
421
|
+
(*!
|
|
422
|
+
* isobject <https://github.com/jonschlinkert/isobject>
|
|
423
|
+
*
|
|
424
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
425
|
+
* Released under the MIT License.
|
|
426
|
+
*)
|
|
427
|
+
|
|
428
|
+
is-plain-object/index.js:
|
|
429
|
+
(*!
|
|
430
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
431
|
+
*
|
|
432
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
433
|
+
* Released under the MIT License.
|
|
434
|
+
*)
|
|
435
|
+
|
|
436
|
+
set-value/index.js:
|
|
437
|
+
(*!
|
|
438
|
+
* set-value <https://github.com/jonschlinkert/set-value>
|
|
439
|
+
*
|
|
440
|
+
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
441
|
+
* Released under the MIT License.
|
|
442
|
+
*)
|
|
443
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwindcss-injector",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "tsup(esbuild) build package template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/sonofmagic/
|
|
11
|
-
"directory": "packages/
|
|
10
|
+
"url": "git+https://github.com/sonofmagic/weapp-tailwindcss.git",
|
|
11
|
+
"directory": "packages/tailwindcss-injector"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/
|
|
14
|
+
"url": "https://github.com/sonofmagic/weapp-tailwindcss/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"sideEffects": false,
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"jiti": "^2.4.1",
|
|
35
|
+
"lilconfig": "^3.1.3",
|
|
34
36
|
"postcss": "^8.4.49",
|
|
35
37
|
"tailwindcss": "^3.4.15"
|
|
36
38
|
},
|