unplugin-tailwindcss-mangle 4.0.0 → 4.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.
@@ -0,0 +1,140 @@
1
+ import {
2
+ __dirname,
3
+ getGroupedEntries,
4
+ path,
5
+ pluginName
6
+ } from "./chunk-SQYX773M.js";
7
+
8
+ // src/core/plugin.ts
9
+ import { createUnplugin } from "unplugin";
10
+
11
+ // src/core/factory.ts
12
+ import { createFilter } from "@rollup/pluginutils";
13
+ import { Context, cssHandler, htmlHandler, jsHandler } from "@tailwindcss-mangle/core";
14
+ import { isCSSRequest } from "is-css-request";
15
+ var WEBPACK_LOADER = path.resolve(__dirname, false ? "../../dist/core/loader.cjs" : "core/loader.cjs");
16
+ var factory = (options) => {
17
+ const ctx = new Context();
18
+ let filter = (_id) => true;
19
+ return [
20
+ {
21
+ name: `${pluginName}:pre`,
22
+ enforce: "pre",
23
+ async buildStart() {
24
+ await ctx.initConfig({
25
+ mangleOptions: options
26
+ });
27
+ filter = createFilter(ctx.options.include, ctx.options.exclude);
28
+ }
29
+ },
30
+ {
31
+ name: `${pluginName}`,
32
+ transformInclude(id) {
33
+ return filter(id);
34
+ },
35
+ async transform(code, id) {
36
+ const opts = {
37
+ ctx,
38
+ id
39
+ };
40
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
41
+ return jsHandler(code, opts);
42
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
43
+ if (isCSSRequest(id)) {
44
+ return await cssHandler(code, opts);
45
+ } else {
46
+ return jsHandler(code, opts);
47
+ }
48
+ } else if (isCSSRequest(id)) {
49
+ return await cssHandler(code, opts);
50
+ } else if (/\.html?/.test(id)) {
51
+ return htmlHandler(code, opts);
52
+ }
53
+ },
54
+ webpack(compiler) {
55
+ const { NormalModule } = compiler.webpack;
56
+ const isExisted = true;
57
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
58
+ NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
59
+ if (isExisted) {
60
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
61
+ if (idx > -1) {
62
+ module.loaders.splice(idx, 0, {
63
+ loader: WEBPACK_LOADER,
64
+ ident: null,
65
+ options: {
66
+ ctx
67
+ },
68
+ type: null
69
+ });
70
+ }
71
+ }
72
+ });
73
+ });
74
+ }
75
+ },
76
+ {
77
+ name: `${pluginName}:post`,
78
+ enforce: "post",
79
+ vite: {
80
+ transformIndexHtml(html) {
81
+ const { code } = htmlHandler(html, { ctx });
82
+ return code;
83
+ }
84
+ // generateBundle: {
85
+ // async handler(options, bundle) {
86
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
87
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
88
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
89
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
90
+ // const { code } = await cssHandler(cssSource.source.toString(), {
91
+ // id,
92
+ // ctx,
93
+ // })
94
+ // cssSource.source = code
95
+ // }
96
+ // }
97
+ // },
98
+ // },
99
+ },
100
+ webpack(compiler) {
101
+ const { Compilation, sources } = compiler.webpack;
102
+ const { ConcatSource } = sources;
103
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
104
+ compilation.hooks.processAssets.tapPromise(
105
+ {
106
+ name: pluginName,
107
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
108
+ },
109
+ async (assets) => {
110
+ const groupedEntries = getGroupedEntries(Object.entries(assets));
111
+ if (groupedEntries.css.length > 0) {
112
+ for (let i = 0; i < groupedEntries.css.length; i++) {
113
+ const [id, cssSource] = groupedEntries.css[i];
114
+ const { code } = await cssHandler(cssSource.source().toString(), {
115
+ id,
116
+ ctx
117
+ });
118
+ const source = new ConcatSource(code);
119
+ compilation.updateAsset(id, source);
120
+ }
121
+ }
122
+ }
123
+ );
124
+ });
125
+ },
126
+ writeBundle() {
127
+ ctx.dump();
128
+ }
129
+ }
130
+ ];
131
+ };
132
+ var factory_default = factory;
133
+
134
+ // src/core/plugin.ts
135
+ var unplugin = createUnplugin(factory_default);
136
+ var plugin_default = unplugin;
137
+
138
+ export {
139
+ plugin_default
140
+ };
@@ -0,0 +1,297 @@
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(); } }// src/utils.ts
2
+ var _promises = require('fs/promises'); var _promises2 = _interopRequireDefault(_promises);
3
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
4
+ var _shared = require('@tailwindcss-mangle/shared');
5
+
6
+ // ../../node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
7
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
8
+ function normalizeWindowsPath(input = "") {
9
+ if (!input) {
10
+ return input;
11
+ }
12
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
13
+ }
14
+ var _UNC_REGEX = /^[/\\]{2}/;
15
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
16
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
17
+ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
18
+ var sep = "/";
19
+ var delimiter = ":";
20
+ var normalize = function(path2) {
21
+ if (path2.length === 0) {
22
+ return ".";
23
+ }
24
+ path2 = normalizeWindowsPath(path2);
25
+ const isUNCPath = path2.match(_UNC_REGEX);
26
+ const isPathAbsolute = isAbsolute(path2);
27
+ const trailingSeparator = path2[path2.length - 1] === "/";
28
+ path2 = normalizeString(path2, !isPathAbsolute);
29
+ if (path2.length === 0) {
30
+ if (isPathAbsolute) {
31
+ return "/";
32
+ }
33
+ return trailingSeparator ? "./" : ".";
34
+ }
35
+ if (trailingSeparator) {
36
+ path2 += "/";
37
+ }
38
+ if (_DRIVE_LETTER_RE.test(path2)) {
39
+ path2 += "/";
40
+ }
41
+ if (isUNCPath) {
42
+ if (!isPathAbsolute) {
43
+ return `//./${path2}`;
44
+ }
45
+ return `//${path2}`;
46
+ }
47
+ return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
48
+ };
49
+ var join = function(...arguments_) {
50
+ if (arguments_.length === 0) {
51
+ return ".";
52
+ }
53
+ let joined;
54
+ for (const argument of arguments_) {
55
+ if (argument && argument.length > 0) {
56
+ if (joined === void 0) {
57
+ joined = argument;
58
+ } else {
59
+ joined += `/${argument}`;
60
+ }
61
+ }
62
+ }
63
+ if (joined === void 0) {
64
+ return ".";
65
+ }
66
+ return normalize(joined.replace(/\/\/+/g, "/"));
67
+ };
68
+ function cwd() {
69
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
70
+ return process.cwd().replace(/\\/g, "/");
71
+ }
72
+ return "/";
73
+ }
74
+ var resolve = function(...arguments_) {
75
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
76
+ let resolvedPath = "";
77
+ let resolvedAbsolute = false;
78
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
79
+ const path2 = index >= 0 ? arguments_[index] : cwd();
80
+ if (!path2 || path2.length === 0) {
81
+ continue;
82
+ }
83
+ resolvedPath = `${path2}/${resolvedPath}`;
84
+ resolvedAbsolute = isAbsolute(path2);
85
+ }
86
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
87
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
88
+ return `/${resolvedPath}`;
89
+ }
90
+ return resolvedPath.length > 0 ? resolvedPath : ".";
91
+ };
92
+ function normalizeString(path2, allowAboveRoot) {
93
+ let res = "";
94
+ let lastSegmentLength = 0;
95
+ let lastSlash = -1;
96
+ let dots = 0;
97
+ let char = null;
98
+ for (let index = 0; index <= path2.length; ++index) {
99
+ if (index < path2.length) {
100
+ char = path2[index];
101
+ } else if (char === "/") {
102
+ break;
103
+ } else {
104
+ char = "/";
105
+ }
106
+ if (char === "/") {
107
+ if (lastSlash === index - 1 || dots === 1) ;
108
+ else if (dots === 2) {
109
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
110
+ if (res.length > 2) {
111
+ const lastSlashIndex = res.lastIndexOf("/");
112
+ if (lastSlashIndex === -1) {
113
+ res = "";
114
+ lastSegmentLength = 0;
115
+ } else {
116
+ res = res.slice(0, lastSlashIndex);
117
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
118
+ }
119
+ lastSlash = index;
120
+ dots = 0;
121
+ continue;
122
+ } else if (res.length > 0) {
123
+ res = "";
124
+ lastSegmentLength = 0;
125
+ lastSlash = index;
126
+ dots = 0;
127
+ continue;
128
+ }
129
+ }
130
+ if (allowAboveRoot) {
131
+ res += res.length > 0 ? "/.." : "..";
132
+ lastSegmentLength = 2;
133
+ }
134
+ } else {
135
+ if (res.length > 0) {
136
+ res += `/${path2.slice(lastSlash + 1, index)}`;
137
+ } else {
138
+ res = path2.slice(lastSlash + 1, index);
139
+ }
140
+ lastSegmentLength = index - lastSlash - 1;
141
+ }
142
+ lastSlash = index;
143
+ dots = 0;
144
+ } else if (char === "." && dots !== -1) {
145
+ ++dots;
146
+ } else {
147
+ dots = -1;
148
+ }
149
+ }
150
+ return res;
151
+ }
152
+ var isAbsolute = function(p) {
153
+ return _IS_ABSOLUTE_RE.test(p);
154
+ };
155
+ var toNamespacedPath = function(p) {
156
+ return normalizeWindowsPath(p);
157
+ };
158
+ var _EXTNAME_RE = /.(\.[^./]+)$/;
159
+ var extname = function(p) {
160
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
161
+ return match && match[1] || "";
162
+ };
163
+ var relative = function(from, to) {
164
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
165
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
166
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
167
+ return _to.join("/");
168
+ }
169
+ const _fromCopy = [..._from];
170
+ for (const segment of _fromCopy) {
171
+ if (_to[0] !== segment) {
172
+ break;
173
+ }
174
+ _from.shift();
175
+ _to.shift();
176
+ }
177
+ return [..._from.map(() => ".."), ..._to].join("/");
178
+ };
179
+ var dirname = function(p) {
180
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
181
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
182
+ segments[0] += "/";
183
+ }
184
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
185
+ };
186
+ var format = function(p) {
187
+ const segments = [p.root, p.dir, _nullishCoalesce(p.base, () => ( p.name + p.ext))].filter(Boolean);
188
+ return normalizeWindowsPath(
189
+ p.root ? resolve(...segments) : segments.join("/")
190
+ );
191
+ };
192
+ var basename = function(p, extension) {
193
+ const lastSegment = normalizeWindowsPath(p).split("/").pop();
194
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
195
+ };
196
+ var parse = function(p) {
197
+ const root = normalizeWindowsPath(p).split("/").shift() || "/";
198
+ const base = basename(p);
199
+ const extension = extname(base);
200
+ return {
201
+ root,
202
+ dir: dirname(p),
203
+ base,
204
+ ext: extension,
205
+ name: base.slice(0, base.length - extension.length)
206
+ };
207
+ };
208
+ var path = {
209
+ __proto__: null,
210
+ basename,
211
+ delimiter,
212
+ dirname,
213
+ extname,
214
+ format,
215
+ isAbsolute,
216
+ join,
217
+ normalize,
218
+ normalizeString,
219
+ parse,
220
+ relative,
221
+ resolve,
222
+ sep,
223
+ toNamespacedPath
224
+ };
225
+
226
+ // src/constants.ts
227
+ var pluginName = "unplugin-tailwindcss-mangle";
228
+
229
+ // src/utils.ts
230
+
231
+ function escapeStringRegexp(str) {
232
+ if (typeof str !== "string") {
233
+ throw new TypeError("Expected a string");
234
+ }
235
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
236
+ }
237
+ function getGroupedEntries(entries, options = {
238
+ cssMatcher(file) {
239
+ return /\.css$/.test(file);
240
+ },
241
+ htmlMatcher(file) {
242
+ return /\.html?$/.test(file);
243
+ },
244
+ jsMatcher(file) {
245
+ return /\.[cm]?js$/.test(file);
246
+ }
247
+ }) {
248
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
249
+ const groupedEntries = _shared.groupBy.call(void 0, entries, ([file]) => {
250
+ if (cssMatcher(file)) {
251
+ return "css";
252
+ } else if (htmlMatcher(file)) {
253
+ return "html";
254
+ } else if (jsMatcher(file)) {
255
+ return "js";
256
+ } else {
257
+ return "other";
258
+ }
259
+ });
260
+ if (!groupedEntries.css) {
261
+ groupedEntries.css = [];
262
+ }
263
+ if (!groupedEntries.html) {
264
+ groupedEntries.html = [];
265
+ }
266
+ if (!groupedEntries.js) {
267
+ groupedEntries.js = [];
268
+ }
269
+ if (!groupedEntries.other) {
270
+ groupedEntries.other = [];
271
+ }
272
+ return groupedEntries;
273
+ }
274
+ function getCacheDir(basedir = _process2.default.cwd()) {
275
+ return path.resolve(basedir, "node_modules/.cache", pluginName);
276
+ }
277
+ async function ensureDir(p) {
278
+ try {
279
+ await _promises2.default.access(p);
280
+ } catch (e) {
281
+ await _promises2.default.mkdir(p, {
282
+ recursive: true
283
+ });
284
+ }
285
+ }
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ exports.path = path; exports.pluginName = pluginName; exports.escapeStringRegexp = escapeStringRegexp; exports.getGroupedEntries = getGroupedEntries; exports.getCacheDir = getCacheDir; exports.ensureDir = ensureDir; exports.defaultMangleClassFilter = _shared.defaultMangleClassFilter; exports.isMap = _shared.isMap; exports.isRegexp = _shared.isRegexp;
@@ -0,0 +1,139 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkQJCZGHDWcjs = require('./chunk-QJCZGHDW.cjs');
6
+
7
+ // src/core/plugin.ts
8
+ var _unplugin = require('unplugin');
9
+
10
+ // src/core/factory.ts
11
+ var _pluginutils = require('@rollup/pluginutils');
12
+ var _core = require('@tailwindcss-mangle/core');
13
+ var _iscssrequest = require('is-css-request');
14
+ var WEBPACK_LOADER = _chunkQJCZGHDWcjs.path.resolve(__dirname, false ? "../../dist/core/loader.cjs" : "core/loader.cjs");
15
+ var factory = (options) => {
16
+ const ctx = new (0, _core.Context)();
17
+ let filter = (_id) => true;
18
+ return [
19
+ {
20
+ name: `${_chunkQJCZGHDWcjs.pluginName}:pre`,
21
+ enforce: "pre",
22
+ async buildStart() {
23
+ await ctx.initConfig({
24
+ mangleOptions: options
25
+ });
26
+ filter = _pluginutils.createFilter.call(void 0, ctx.options.include, ctx.options.exclude);
27
+ }
28
+ },
29
+ {
30
+ name: `${_chunkQJCZGHDWcjs.pluginName}`,
31
+ transformInclude(id) {
32
+ return filter(id);
33
+ },
34
+ async transform(code, id) {
35
+ const opts = {
36
+ ctx,
37
+ id
38
+ };
39
+ if (/\.[jt]sx?(?:$|\?)/.test(id)) {
40
+ return _core.jsHandler.call(void 0, code, opts);
41
+ } else if (/\.(?:vue|svelte)(?:$|\?)/.test(id)) {
42
+ if (_iscssrequest.isCSSRequest.call(void 0, id)) {
43
+ return await _core.cssHandler.call(void 0, code, opts);
44
+ } else {
45
+ return _core.jsHandler.call(void 0, code, opts);
46
+ }
47
+ } else if (_iscssrequest.isCSSRequest.call(void 0, id)) {
48
+ return await _core.cssHandler.call(void 0, code, opts);
49
+ } else if (/\.html?/.test(id)) {
50
+ return _core.htmlHandler.call(void 0, code, opts);
51
+ }
52
+ },
53
+ webpack(compiler) {
54
+ const { NormalModule } = compiler.webpack;
55
+ const isExisted = true;
56
+ compiler.hooks.compilation.tap(_chunkQJCZGHDWcjs.pluginName, (compilation) => {
57
+ NormalModule.getCompilationHooks(compilation).loader.tap(_chunkQJCZGHDWcjs.pluginName, (_loaderContext, module) => {
58
+ if (isExisted) {
59
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
60
+ if (idx > -1) {
61
+ module.loaders.splice(idx, 0, {
62
+ loader: WEBPACK_LOADER,
63
+ ident: null,
64
+ options: {
65
+ ctx
66
+ },
67
+ type: null
68
+ });
69
+ }
70
+ }
71
+ });
72
+ });
73
+ }
74
+ },
75
+ {
76
+ name: `${_chunkQJCZGHDWcjs.pluginName}:post`,
77
+ enforce: "post",
78
+ vite: {
79
+ transformIndexHtml(html) {
80
+ const { code } = _core.htmlHandler.call(void 0, html, { ctx });
81
+ return code;
82
+ }
83
+ // generateBundle: {
84
+ // async handler(options, bundle) {
85
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
86
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
87
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
88
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
89
+ // const { code } = await cssHandler(cssSource.source.toString(), {
90
+ // id,
91
+ // ctx,
92
+ // })
93
+ // cssSource.source = code
94
+ // }
95
+ // }
96
+ // },
97
+ // },
98
+ },
99
+ webpack(compiler) {
100
+ const { Compilation, sources } = compiler.webpack;
101
+ const { ConcatSource } = sources;
102
+ compiler.hooks.compilation.tap(_chunkQJCZGHDWcjs.pluginName, (compilation) => {
103
+ compilation.hooks.processAssets.tapPromise(
104
+ {
105
+ name: _chunkQJCZGHDWcjs.pluginName,
106
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
107
+ },
108
+ async (assets) => {
109
+ const groupedEntries = _chunkQJCZGHDWcjs.getGroupedEntries.call(void 0, Object.entries(assets));
110
+ if (groupedEntries.css.length > 0) {
111
+ for (let i = 0; i < groupedEntries.css.length; i++) {
112
+ const [id, cssSource] = groupedEntries.css[i];
113
+ const { code } = await _core.cssHandler.call(void 0, cssSource.source().toString(), {
114
+ id,
115
+ ctx
116
+ });
117
+ const source = new ConcatSource(code);
118
+ compilation.updateAsset(id, source);
119
+ }
120
+ }
121
+ }
122
+ );
123
+ });
124
+ },
125
+ writeBundle() {
126
+ ctx.dump();
127
+ }
128
+ }
129
+ ];
130
+ };
131
+ var factory_default = factory;
132
+
133
+ // src/core/plugin.ts
134
+ var unplugin = _unplugin.createUnplugin.call(void 0, factory_default);
135
+ var plugin_default = unplugin;
136
+
137
+
138
+
139
+ exports.plugin_default = plugin_default;
@@ -0,0 +1,305 @@
1
+ // ../../node_modules/.pnpm/tsup@8.3.5_jiti@2.3.3_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/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/utils.ts
9
+ import fs from "node:fs/promises";
10
+ import process2 from "node:process";
11
+ import { groupBy } from "@tailwindcss-mangle/shared";
12
+
13
+ // ../../node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
14
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
15
+ function normalizeWindowsPath(input = "") {
16
+ if (!input) {
17
+ return input;
18
+ }
19
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
20
+ }
21
+ var _UNC_REGEX = /^[/\\]{2}/;
22
+ var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
23
+ var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
24
+ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
25
+ var sep = "/";
26
+ var delimiter = ":";
27
+ var normalize = function(path3) {
28
+ if (path3.length === 0) {
29
+ return ".";
30
+ }
31
+ path3 = normalizeWindowsPath(path3);
32
+ const isUNCPath = path3.match(_UNC_REGEX);
33
+ const isPathAbsolute = isAbsolute(path3);
34
+ const trailingSeparator = path3[path3.length - 1] === "/";
35
+ path3 = normalizeString(path3, !isPathAbsolute);
36
+ if (path3.length === 0) {
37
+ if (isPathAbsolute) {
38
+ return "/";
39
+ }
40
+ return trailingSeparator ? "./" : ".";
41
+ }
42
+ if (trailingSeparator) {
43
+ path3 += "/";
44
+ }
45
+ if (_DRIVE_LETTER_RE.test(path3)) {
46
+ path3 += "/";
47
+ }
48
+ if (isUNCPath) {
49
+ if (!isPathAbsolute) {
50
+ return `//./${path3}`;
51
+ }
52
+ return `//${path3}`;
53
+ }
54
+ return isPathAbsolute && !isAbsolute(path3) ? `/${path3}` : path3;
55
+ };
56
+ var join = function(...arguments_) {
57
+ if (arguments_.length === 0) {
58
+ return ".";
59
+ }
60
+ let joined;
61
+ for (const argument of arguments_) {
62
+ if (argument && argument.length > 0) {
63
+ if (joined === void 0) {
64
+ joined = argument;
65
+ } else {
66
+ joined += `/${argument}`;
67
+ }
68
+ }
69
+ }
70
+ if (joined === void 0) {
71
+ return ".";
72
+ }
73
+ return normalize(joined.replace(/\/\/+/g, "/"));
74
+ };
75
+ function cwd() {
76
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
77
+ return process.cwd().replace(/\\/g, "/");
78
+ }
79
+ return "/";
80
+ }
81
+ var resolve = function(...arguments_) {
82
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
83
+ let resolvedPath = "";
84
+ let resolvedAbsolute = false;
85
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
86
+ const path3 = index >= 0 ? arguments_[index] : cwd();
87
+ if (!path3 || path3.length === 0) {
88
+ continue;
89
+ }
90
+ resolvedPath = `${path3}/${resolvedPath}`;
91
+ resolvedAbsolute = isAbsolute(path3);
92
+ }
93
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
94
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
95
+ return `/${resolvedPath}`;
96
+ }
97
+ return resolvedPath.length > 0 ? resolvedPath : ".";
98
+ };
99
+ function normalizeString(path3, allowAboveRoot) {
100
+ let res = "";
101
+ let lastSegmentLength = 0;
102
+ let lastSlash = -1;
103
+ let dots = 0;
104
+ let char = null;
105
+ for (let index = 0; index <= path3.length; ++index) {
106
+ if (index < path3.length) {
107
+ char = path3[index];
108
+ } else if (char === "/") {
109
+ break;
110
+ } else {
111
+ char = "/";
112
+ }
113
+ if (char === "/") {
114
+ if (lastSlash === index - 1 || dots === 1) ;
115
+ else if (dots === 2) {
116
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
117
+ if (res.length > 2) {
118
+ const lastSlashIndex = res.lastIndexOf("/");
119
+ if (lastSlashIndex === -1) {
120
+ res = "";
121
+ lastSegmentLength = 0;
122
+ } else {
123
+ res = res.slice(0, lastSlashIndex);
124
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
125
+ }
126
+ lastSlash = index;
127
+ dots = 0;
128
+ continue;
129
+ } else if (res.length > 0) {
130
+ res = "";
131
+ lastSegmentLength = 0;
132
+ lastSlash = index;
133
+ dots = 0;
134
+ continue;
135
+ }
136
+ }
137
+ if (allowAboveRoot) {
138
+ res += res.length > 0 ? "/.." : "..";
139
+ lastSegmentLength = 2;
140
+ }
141
+ } else {
142
+ if (res.length > 0) {
143
+ res += `/${path3.slice(lastSlash + 1, index)}`;
144
+ } else {
145
+ res = path3.slice(lastSlash + 1, index);
146
+ }
147
+ lastSegmentLength = index - lastSlash - 1;
148
+ }
149
+ lastSlash = index;
150
+ dots = 0;
151
+ } else if (char === "." && dots !== -1) {
152
+ ++dots;
153
+ } else {
154
+ dots = -1;
155
+ }
156
+ }
157
+ return res;
158
+ }
159
+ var isAbsolute = function(p) {
160
+ return _IS_ABSOLUTE_RE.test(p);
161
+ };
162
+ var toNamespacedPath = function(p) {
163
+ return normalizeWindowsPath(p);
164
+ };
165
+ var _EXTNAME_RE = /.(\.[^./]+)$/;
166
+ var extname = function(p) {
167
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
168
+ return match && match[1] || "";
169
+ };
170
+ var relative = function(from, to) {
171
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
172
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
173
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
174
+ return _to.join("/");
175
+ }
176
+ const _fromCopy = [..._from];
177
+ for (const segment of _fromCopy) {
178
+ if (_to[0] !== segment) {
179
+ break;
180
+ }
181
+ _from.shift();
182
+ _to.shift();
183
+ }
184
+ return [..._from.map(() => ".."), ..._to].join("/");
185
+ };
186
+ var dirname = function(p) {
187
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
188
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
189
+ segments[0] += "/";
190
+ }
191
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
192
+ };
193
+ var format = function(p) {
194
+ const segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
195
+ return normalizeWindowsPath(
196
+ p.root ? resolve(...segments) : segments.join("/")
197
+ );
198
+ };
199
+ var basename = function(p, extension) {
200
+ const lastSegment = normalizeWindowsPath(p).split("/").pop();
201
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
202
+ };
203
+ var parse = function(p) {
204
+ const root = normalizeWindowsPath(p).split("/").shift() || "/";
205
+ const base = basename(p);
206
+ const extension = extname(base);
207
+ return {
208
+ root,
209
+ dir: dirname(p),
210
+ base,
211
+ ext: extension,
212
+ name: base.slice(0, base.length - extension.length)
213
+ };
214
+ };
215
+ var path2 = {
216
+ __proto__: null,
217
+ basename,
218
+ delimiter,
219
+ dirname,
220
+ extname,
221
+ format,
222
+ isAbsolute,
223
+ join,
224
+ normalize,
225
+ normalizeString,
226
+ parse,
227
+ relative,
228
+ resolve,
229
+ sep,
230
+ toNamespacedPath
231
+ };
232
+
233
+ // src/constants.ts
234
+ var pluginName = "unplugin-tailwindcss-mangle";
235
+
236
+ // src/utils.ts
237
+ import { defaultMangleClassFilter, isMap, isRegexp } from "@tailwindcss-mangle/shared";
238
+ function escapeStringRegexp(str) {
239
+ if (typeof str !== "string") {
240
+ throw new TypeError("Expected a string");
241
+ }
242
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
243
+ }
244
+ function getGroupedEntries(entries, options = {
245
+ cssMatcher(file) {
246
+ return /\.css$/.test(file);
247
+ },
248
+ htmlMatcher(file) {
249
+ return /\.html?$/.test(file);
250
+ },
251
+ jsMatcher(file) {
252
+ return /\.[cm]?js$/.test(file);
253
+ }
254
+ }) {
255
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
256
+ const groupedEntries = groupBy(entries, ([file]) => {
257
+ if (cssMatcher(file)) {
258
+ return "css";
259
+ } else if (htmlMatcher(file)) {
260
+ return "html";
261
+ } else if (jsMatcher(file)) {
262
+ return "js";
263
+ } else {
264
+ return "other";
265
+ }
266
+ });
267
+ if (!groupedEntries.css) {
268
+ groupedEntries.css = [];
269
+ }
270
+ if (!groupedEntries.html) {
271
+ groupedEntries.html = [];
272
+ }
273
+ if (!groupedEntries.js) {
274
+ groupedEntries.js = [];
275
+ }
276
+ if (!groupedEntries.other) {
277
+ groupedEntries.other = [];
278
+ }
279
+ return groupedEntries;
280
+ }
281
+ function getCacheDir(basedir = process2.cwd()) {
282
+ return path2.resolve(basedir, "node_modules/.cache", pluginName);
283
+ }
284
+ async function ensureDir(p) {
285
+ try {
286
+ await fs.access(p);
287
+ } catch {
288
+ await fs.mkdir(p, {
289
+ recursive: true
290
+ });
291
+ }
292
+ }
293
+
294
+ export {
295
+ __dirname,
296
+ path2 as path,
297
+ pluginName,
298
+ escapeStringRegexp,
299
+ getGroupedEntries,
300
+ getCacheDir,
301
+ ensureDir,
302
+ defaultMangleClassFilter,
303
+ isMap,
304
+ isRegexp
305
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+ // src/esbuild.ts
7
+ var esbuild_default = _chunkQSSGNNXYcjs.plugin_default.esbuild;
8
+
9
+
10
+ exports.default = esbuild_default;
11
+
12
+ module.exports = exports.default;
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
+
6
+ export = _default;
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
+
6
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+
6
+ // src/esbuild.ts
7
+ var esbuild_default = plugin_default.esbuild;
8
+ export {
9
+ esbuild_default as default
10
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+
7
+ exports.default = _chunkQSSGNNXYcjs.plugin_default;
8
+
9
+ module.exports = exports.default;
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
+
6
+ export = unplugin;
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
+
6
+ export { unplugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+ export {
6
+ plugin_default as default
7
+ };
package/dist/nuxt.cjs ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+ // src/nuxt.ts
7
+ function nuxt_default(options = {}, nuxt) {
8
+ nuxt.hook("webpack:config", (config) => {
9
+ config.plugins = config.plugins || [];
10
+ config.plugins.unshift(_chunkQSSGNNXYcjs.plugin_default.webpack(options));
11
+ });
12
+ nuxt.hook("vite:extendConfig", (config) => {
13
+ config.plugins = config.plugins || [];
14
+ config.plugins.push(_chunkQSSGNNXYcjs.plugin_default.vite(options));
15
+ });
16
+ }
17
+
18
+
19
+ exports.default = nuxt_default;
20
+
21
+ module.exports = exports.default;
@@ -0,0 +1,5 @@
1
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+
3
+ declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
+
5
+ export = export_default;
package/dist/nuxt.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
+
3
+ declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
+
5
+ export { export_default as default };
package/dist/nuxt.js ADDED
@@ -0,0 +1,19 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+
6
+ // src/nuxt.ts
7
+ function nuxt_default(options = {}, nuxt) {
8
+ nuxt.hook("webpack:config", (config) => {
9
+ config.plugins = config.plugins || [];
10
+ config.plugins.unshift(plugin_default.webpack(options));
11
+ });
12
+ nuxt.hook("vite:extendConfig", (config) => {
13
+ config.plugins = config.plugins || [];
14
+ config.plugins.push(plugin_default.vite(options));
15
+ });
16
+ }
17
+ export {
18
+ nuxt_default as default
19
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+ // src/rollup.ts
7
+ var rollup_default = _chunkQSSGNNXYcjs.plugin_default.rollup;
8
+
9
+
10
+ exports.default = rollup_default;
11
+
12
+ module.exports = exports.default;
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export = _default;
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export { _default as default };
package/dist/rollup.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+
6
+ // src/rollup.ts
7
+ var rollup_default = plugin_default.rollup;
8
+ export {
9
+ rollup_default as default
10
+ };
package/dist/utils.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkQJCZGHDWcjs = require('./chunk-QJCZGHDW.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ exports.defaultMangleClassFilter = _chunkQJCZGHDWcjs.defaultMangleClassFilter; exports.ensureDir = _chunkQJCZGHDWcjs.ensureDir; exports.escapeStringRegexp = _chunkQJCZGHDWcjs.escapeStringRegexp; exports.getCacheDir = _chunkQJCZGHDWcjs.getCacheDir; exports.getGroupedEntries = _chunkQJCZGHDWcjs.getGroupedEntries; exports.isMap = _chunkQJCZGHDWcjs.isMap; exports.isRegexp = _chunkQJCZGHDWcjs.isRegexp;
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/utils.js ADDED
@@ -0,0 +1,18 @@
1
+ import {
2
+ defaultMangleClassFilter,
3
+ ensureDir,
4
+ escapeStringRegexp,
5
+ getCacheDir,
6
+ getGroupedEntries,
7
+ isMap,
8
+ isRegexp
9
+ } from "./chunk-SQYX773M.js";
10
+ export {
11
+ defaultMangleClassFilter,
12
+ ensureDir,
13
+ escapeStringRegexp,
14
+ getCacheDir,
15
+ getGroupedEntries,
16
+ isMap,
17
+ isRegexp
18
+ };
package/dist/vite.cjs ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+ // src/vite.ts
7
+ var vite_default = _chunkQSSGNNXYcjs.plugin_default.vite;
8
+
9
+
10
+ exports.default = vite_default;
11
+
12
+ module.exports = exports.default;
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
+
6
+ export = _default;
package/dist/vite.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
+
6
+ export { _default as default };
package/dist/vite.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+
6
+ // src/vite.ts
7
+ var vite_default = plugin_default.vite;
8
+ export {
9
+ vite_default as default
10
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkQSSGNNXYcjs = require('./chunk-QSSGNNXY.cjs');
4
+ require('./chunk-QJCZGHDW.cjs');
5
+
6
+ // src/webpack.ts
7
+ var webpack_default = _chunkQSSGNNXYcjs.plugin_default.webpack;
8
+
9
+
10
+ exports.default = webpack_default;
11
+
12
+ module.exports = exports.default;
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
+
6
+ export = _default;
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
+
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
+
6
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ import {
2
+ plugin_default
3
+ } from "./chunk-DLPKB44Y.js";
4
+ import "./chunk-SQYX773M.js";
5
+
6
+ // src/webpack.ts
7
+ var webpack_default = plugin_default.webpack;
8
+ export {
9
+ webpack_default as default
10
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.0.1",
5
5
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -69,9 +69,9 @@
69
69
  "is-css-request": "^1.0.1",
70
70
  "magic-string": "^0.30.12",
71
71
  "unplugin": "^1.14.1",
72
- "@tailwindcss-mangle/config": "^4.0.0",
73
- "@tailwindcss-mangle/core": "^4.0.0",
74
- "@tailwindcss-mangle/shared": "^4.0.0"
72
+ "@tailwindcss-mangle/config": "^4.0.1",
73
+ "@tailwindcss-mangle/core": "^4.0.1",
74
+ "@tailwindcss-mangle/shared": "^4.0.1"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public",