@tailwind-styled/vite 2.0.0
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/dist/plugin.cjs +128 -0
- package/dist/plugin.d.cts +22 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.js +96 -0
- package/package.json +34 -0
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/plugin.ts
|
|
60
|
+
var plugin_exports = {};
|
|
61
|
+
__export(plugin_exports, {
|
|
62
|
+
default: () => plugin_default,
|
|
63
|
+
tailwindStyledPlugin: () => tailwindStyledPlugin
|
|
64
|
+
});
|
|
65
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
66
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
67
|
+
var import_compiler = require("@tailwind-styled/compiler");
|
|
68
|
+
function tailwindStyledPlugin(opts = {}) {
|
|
69
|
+
const _a = opts, {
|
|
70
|
+
include = /\.(tsx|ts|jsx|js)$/,
|
|
71
|
+
exclude = /node_modules/,
|
|
72
|
+
scanDirs = ["src"],
|
|
73
|
+
safelistOutput = ".tailwind-styled-safelist.json",
|
|
74
|
+
generateSafelist: doSafelist = true
|
|
75
|
+
} = _a, transformOpts = __objRest(_a, [
|
|
76
|
+
"include",
|
|
77
|
+
"exclude",
|
|
78
|
+
"scanDirs",
|
|
79
|
+
"safelistOutput",
|
|
80
|
+
"generateSafelist"
|
|
81
|
+
]);
|
|
82
|
+
let root = process.cwd();
|
|
83
|
+
let isDev = true;
|
|
84
|
+
return {
|
|
85
|
+
name: "tailwind-styled-v4",
|
|
86
|
+
enforce: "pre",
|
|
87
|
+
configResolved(config) {
|
|
88
|
+
root = config.root;
|
|
89
|
+
isDev = config.command === "serve";
|
|
90
|
+
},
|
|
91
|
+
transform(source, id) {
|
|
92
|
+
var _a2, _b;
|
|
93
|
+
const filepath = id.split("?")[0];
|
|
94
|
+
if (!include.test(filepath)) return null;
|
|
95
|
+
if (exclude.test(filepath)) return null;
|
|
96
|
+
if (!(0, import_compiler.shouldProcess)(filepath)) return null;
|
|
97
|
+
const result = (0, import_compiler.transformSource)(source, __spreadProps(__spreadValues({}, transformOpts), {
|
|
98
|
+
mode: (_a2 = transformOpts.mode) != null ? _a2 : isDev ? "runtime" : "zero-runtime",
|
|
99
|
+
addDataAttr: (_b = transformOpts.addDataAttr) != null ? _b : isDev,
|
|
100
|
+
filename: filepath
|
|
101
|
+
}));
|
|
102
|
+
if (!result.changed) return null;
|
|
103
|
+
return { code: result.code, map: null };
|
|
104
|
+
},
|
|
105
|
+
buildEnd() {
|
|
106
|
+
if (!doSafelist || isDev) return;
|
|
107
|
+
try {
|
|
108
|
+
(0, import_compiler.generateSafelist)(
|
|
109
|
+
scanDirs.map((d) => import_node_path.default.resolve(root, d)),
|
|
110
|
+
import_node_path.default.resolve(root, safelistOutput),
|
|
111
|
+
root
|
|
112
|
+
);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.warn("[tailwind-styled-v4] Safelist generation failed:", e);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
handleHotUpdate({ file, server }) {
|
|
118
|
+
if (include.test(file) && (0, import_compiler.shouldProcess)(file)) {
|
|
119
|
+
server.ws.send({ type: "full-reload" });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
var plugin_default = tailwindStyledPlugin;
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
tailwindStyledPlugin
|
|
128
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TransformOptions } from '@tailwind-styled/compiler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* tailwind-styled-v4 — Vite Plugin
|
|
5
|
+
*
|
|
6
|
+
* Usage in vite.config.ts:
|
|
7
|
+
* import { tailwindStyledPlugin } from "tailwind-styled-v4/vite"
|
|
8
|
+
* export default defineConfig({
|
|
9
|
+
* plugins: [react(), tailwindStyledPlugin()]
|
|
10
|
+
* })
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface VitePluginOptions extends TransformOptions {
|
|
14
|
+
include?: RegExp;
|
|
15
|
+
exclude?: RegExp;
|
|
16
|
+
scanDirs?: string[];
|
|
17
|
+
safelistOutput?: string;
|
|
18
|
+
generateSafelist?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function tailwindStyledPlugin(opts?: VitePluginOptions): any;
|
|
21
|
+
|
|
22
|
+
export { type VitePluginOptions, tailwindStyledPlugin as default, tailwindStyledPlugin };
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TransformOptions } from '@tailwind-styled/compiler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* tailwind-styled-v4 — Vite Plugin
|
|
5
|
+
*
|
|
6
|
+
* Usage in vite.config.ts:
|
|
7
|
+
* import { tailwindStyledPlugin } from "tailwind-styled-v4/vite"
|
|
8
|
+
* export default defineConfig({
|
|
9
|
+
* plugins: [react(), tailwindStyledPlugin()]
|
|
10
|
+
* })
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface VitePluginOptions extends TransformOptions {
|
|
14
|
+
include?: RegExp;
|
|
15
|
+
exclude?: RegExp;
|
|
16
|
+
scanDirs?: string[];
|
|
17
|
+
safelistOutput?: string;
|
|
18
|
+
generateSafelist?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare function tailwindStyledPlugin(opts?: VitePluginOptions): any;
|
|
21
|
+
|
|
22
|
+
export { type VitePluginOptions, tailwindStyledPlugin as default, tailwindStyledPlugin };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/plugin.ts
|
|
34
|
+
import path from "path";
|
|
35
|
+
import { generateSafelist, shouldProcess, transformSource } from "@tailwind-styled/compiler";
|
|
36
|
+
function tailwindStyledPlugin(opts = {}) {
|
|
37
|
+
const _a = opts, {
|
|
38
|
+
include = /\.(tsx|ts|jsx|js)$/,
|
|
39
|
+
exclude = /node_modules/,
|
|
40
|
+
scanDirs = ["src"],
|
|
41
|
+
safelistOutput = ".tailwind-styled-safelist.json",
|
|
42
|
+
generateSafelist: doSafelist = true
|
|
43
|
+
} = _a, transformOpts = __objRest(_a, [
|
|
44
|
+
"include",
|
|
45
|
+
"exclude",
|
|
46
|
+
"scanDirs",
|
|
47
|
+
"safelistOutput",
|
|
48
|
+
"generateSafelist"
|
|
49
|
+
]);
|
|
50
|
+
let root = process.cwd();
|
|
51
|
+
let isDev = true;
|
|
52
|
+
return {
|
|
53
|
+
name: "tailwind-styled-v4",
|
|
54
|
+
enforce: "pre",
|
|
55
|
+
configResolved(config) {
|
|
56
|
+
root = config.root;
|
|
57
|
+
isDev = config.command === "serve";
|
|
58
|
+
},
|
|
59
|
+
transform(source, id) {
|
|
60
|
+
var _a2, _b;
|
|
61
|
+
const filepath = id.split("?")[0];
|
|
62
|
+
if (!include.test(filepath)) return null;
|
|
63
|
+
if (exclude.test(filepath)) return null;
|
|
64
|
+
if (!shouldProcess(filepath)) return null;
|
|
65
|
+
const result = transformSource(source, __spreadProps(__spreadValues({}, transformOpts), {
|
|
66
|
+
mode: (_a2 = transformOpts.mode) != null ? _a2 : isDev ? "runtime" : "zero-runtime",
|
|
67
|
+
addDataAttr: (_b = transformOpts.addDataAttr) != null ? _b : isDev,
|
|
68
|
+
filename: filepath
|
|
69
|
+
}));
|
|
70
|
+
if (!result.changed) return null;
|
|
71
|
+
return { code: result.code, map: null };
|
|
72
|
+
},
|
|
73
|
+
buildEnd() {
|
|
74
|
+
if (!doSafelist || isDev) return;
|
|
75
|
+
try {
|
|
76
|
+
generateSafelist(
|
|
77
|
+
scanDirs.map((d) => path.resolve(root, d)),
|
|
78
|
+
path.resolve(root, safelistOutput),
|
|
79
|
+
root
|
|
80
|
+
);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn("[tailwind-styled-v4] Safelist generation failed:", e);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
handleHotUpdate({ file, server }) {
|
|
86
|
+
if (include.test(file) && shouldProcess(file)) {
|
|
87
|
+
server.ws.send({ type: "full-reload" });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var plugin_default = tailwindStyledPlugin;
|
|
93
|
+
export {
|
|
94
|
+
plugin_default as default,
|
|
95
|
+
tailwindStyledPlugin
|
|
96
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tailwind-styled/vite",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Vite plugin for tailwind-styled-v4 — compile-time transform, safelist generation",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/plugin.cjs",
|
|
8
|
+
"module": "./dist/plugin.js",
|
|
9
|
+
"types": "./dist/plugin.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/plugin.d.ts",
|
|
13
|
+
"import": "./dist/plugin.js",
|
|
14
|
+
"require": "./dist/plugin.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"dev": "tsup --watch"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@tailwind-styled/compiler": "2.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vite": ">=5"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"tsup": "^8",
|
|
30
|
+
"typescript": "^5",
|
|
31
|
+
"@types/node": "^20",
|
|
32
|
+
"vite": "^5"
|
|
33
|
+
}
|
|
34
|
+
}
|