unplugin-tailwindcss-mangle 0.1.3 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/esbuild.js +2 -7
- package/dist/esbuild.mjs +2 -7
- package/dist/index.js +90 -229
- package/dist/index.mjs +67 -207
- package/dist/loader/twm-css.d.ts +1 -1
- package/dist/nuxt.js +2 -7
- package/dist/nuxt.mjs +2 -7
- package/dist/options.d.ts +1 -1
- package/dist/rollup.js +2 -7
- package/dist/rollup.mjs +2 -7
- package/dist/twm-css.js +2 -4
- package/dist/twm-css.mjs +1 -3
- package/dist/types.d.ts +2 -10
- package/dist/utils.d.ts +2 -10
- package/dist/vite.js +2 -7
- package/dist/vite.mjs +2 -7
- package/dist/webpack.js +2 -7
- package/dist/webpack.mjs +2 -7
- package/package.json +7 -16
- package/dist/classGenerator.d.ts +0 -17
- package/dist/css/index.d.ts +0 -2
- package/dist/css/plugins.d.ts +0 -5
- package/dist/html/index.d.ts +0 -2
- package/dist/index-2edd594b.js +0 -246
- package/dist/index-92f879d3.mjs +0 -211
- package/dist/index-b715a07f.mjs +0 -79
- package/dist/index-c8e1bdc5.js +0 -86
- package/dist/js/index.d.ts +0 -6
- package/dist/js/split.d.ts +0 -3
- package/dist/loader/twm-js.d.ts +0 -6
- package/dist/twm-js.js +0 -26
- package/dist/twm-js.mjs +0 -24
package/dist/index.mjs
CHANGED
|
@@ -1,231 +1,91 @@
|
|
|
1
1
|
import { createUnplugin } from 'unplugin';
|
|
2
|
-
import
|
|
3
|
-
import { html, defaultTreeAdapter, parse, serialize } from 'parse5';
|
|
4
|
-
import { c as cssHandler } from './index-b715a07f.mjs';
|
|
5
|
-
import path from 'path';
|
|
2
|
+
import micromatch from 'micromatch';
|
|
6
3
|
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { groupBy, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
6
|
+
import { ClassGenerator, htmlHandler, jsHandler, cssHandler } from 'tailwindcss-mangle-core';
|
|
7
7
|
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
8
|
-
import '@babel/types';
|
|
9
|
-
import '@babel/core';
|
|
10
|
-
import 'micromatch';
|
|
11
|
-
import 'postcss';
|
|
12
|
-
import 'postcss-selector-parser';
|
|
13
|
-
|
|
14
|
-
({
|
|
15
|
-
HTML: html.NS.HTML,
|
|
16
|
-
XML: html.NS.XML,
|
|
17
|
-
MATHML: html.NS.MATHML,
|
|
18
|
-
SVG: html.NS.SVG,
|
|
19
|
-
XLINK: html.NS.XLINK,
|
|
20
|
-
XMLNS: html.NS.XMLNS
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Determines if a given node is a document or not
|
|
25
|
-
* @param {Node} node Node to test
|
|
26
|
-
* @return {boolean}
|
|
27
|
-
*/
|
|
28
|
-
function isDocument(node) {
|
|
29
|
-
return node.nodeName === '#document';
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Determines if a given node is a document fragment or not
|
|
33
|
-
* @param {Node} node Node to test
|
|
34
|
-
* @return {boolean}
|
|
35
|
-
*/
|
|
36
|
-
function isDocumentFragment(node) {
|
|
37
|
-
return node.nodeName === '#document-fragment';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Determines if a given node is a template node or not
|
|
41
|
-
* @param {Node} node Node to test
|
|
42
|
-
* @return {boolean}
|
|
43
|
-
*/
|
|
44
|
-
function isTemplateNode(node) {
|
|
45
|
-
return node.nodeName === 'template';
|
|
46
|
-
}
|
|
47
|
-
const isElementNode = defaultTreeAdapter.isElementNode;
|
|
48
|
-
const isCommentNode = defaultTreeAdapter.isCommentNode;
|
|
49
|
-
const isDocumentTypeNode = defaultTreeAdapter.isDocumentTypeNode;
|
|
50
|
-
const isTextNode = defaultTreeAdapter.isTextNode;
|
|
51
|
-
/**
|
|
52
|
-
* Determines if a given node is a parent or not
|
|
53
|
-
* @param {Node} node Node to test
|
|
54
|
-
* @return {boolean}
|
|
55
|
-
*/
|
|
56
|
-
function isParentNode(node) {
|
|
57
|
-
return (isDocument(node) ||
|
|
58
|
-
isDocumentFragment(node) ||
|
|
59
|
-
isElementNode(node) ||
|
|
60
|
-
isTemplateNode(node));
|
|
61
|
-
}
|
|
62
8
|
|
|
63
|
-
|
|
9
|
+
const pluginName = 'unplugin-tailwindcss-mangle';
|
|
64
10
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (shouldVisitChildren && isParentNode(node)) {
|
|
76
|
-
for (const child of node.childNodes) {
|
|
77
|
-
traverse(child, visitor, node);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (typeof visitor.node === 'function') {
|
|
81
|
-
visitor.node(node, parent);
|
|
82
|
-
}
|
|
83
|
-
if (typeof visitor.document === 'function' && isDocument(node)) {
|
|
84
|
-
visitor.document(node);
|
|
11
|
+
const { isMatch } = micromatch;
|
|
12
|
+
function getGroupedEntries(entries, options = {
|
|
13
|
+
cssMatcher(file) {
|
|
14
|
+
return /\.css$/.test(file);
|
|
15
|
+
},
|
|
16
|
+
htmlMatcher(file) {
|
|
17
|
+
return /\.html?$/.test(file);
|
|
18
|
+
},
|
|
19
|
+
jsMatcher(file) {
|
|
20
|
+
return /\.[cm]?js$/.test(file);
|
|
85
21
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
visitor.element(node, parent);
|
|
92
|
-
}
|
|
93
|
-
if (typeof visitor.template === 'function' && isTemplateNode(node)) {
|
|
94
|
-
visitor.template(node, parent);
|
|
95
|
-
}
|
|
96
|
-
if (typeof visitor.comment === 'function' && isCommentNode(node)) {
|
|
97
|
-
visitor.comment(node, parent);
|
|
98
|
-
}
|
|
99
|
-
if (typeof visitor.text === 'function' && isTextNode(node)) {
|
|
100
|
-
visitor.text(node, parent);
|
|
101
|
-
}
|
|
102
|
-
if (typeof visitor.documentType === 'function' && isDocumentTypeNode(node)) {
|
|
103
|
-
visitor.documentType(node, parent);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function htmlHandler(rawSource, options) {
|
|
108
|
-
const { runtimeSet, classGenerator } = options;
|
|
109
|
-
const fragment = parse(rawSource);
|
|
110
|
-
traverse(fragment, {
|
|
111
|
-
element(node, parent) {
|
|
112
|
-
const attr = node.attrs.find((x) => x.name === 'class');
|
|
113
|
-
if (attr) {
|
|
114
|
-
const arr = attr.value.split(/\s/).filter((x) => x);
|
|
115
|
-
attr.value = arr
|
|
116
|
-
.map((x) => {
|
|
117
|
-
if (runtimeSet.has(x)) {
|
|
118
|
-
return classGenerator.generateClassName(x).name;
|
|
119
|
-
}
|
|
120
|
-
return x;
|
|
121
|
-
})
|
|
122
|
-
.join(' ');
|
|
123
|
-
}
|
|
22
|
+
}) {
|
|
23
|
+
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
24
|
+
const groupedEntries = groupBy(entries, ([file]) => {
|
|
25
|
+
if (cssMatcher(file)) {
|
|
26
|
+
return 'css';
|
|
124
27
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
class ClassGenerator {
|
|
130
|
-
newClassMap;
|
|
131
|
-
newClassSize;
|
|
132
|
-
context;
|
|
133
|
-
opts;
|
|
134
|
-
classPrefix;
|
|
135
|
-
constructor(opts = {}) {
|
|
136
|
-
this.newClassMap = {};
|
|
137
|
-
this.newClassSize = 0;
|
|
138
|
-
this.context = {};
|
|
139
|
-
this.opts = opts;
|
|
140
|
-
this.classPrefix = opts.classPrefix ?? 'tw-';
|
|
141
|
-
}
|
|
142
|
-
defaultClassGenerate() {
|
|
143
|
-
const chars = [];
|
|
144
|
-
let rest = (this.newClassSize - (this.newClassSize % acceptChars.length)) / acceptChars.length;
|
|
145
|
-
if (rest > 0) {
|
|
146
|
-
while (true) {
|
|
147
|
-
rest -= 1;
|
|
148
|
-
const m = rest % acceptChars.length;
|
|
149
|
-
const c = acceptChars[m];
|
|
150
|
-
chars.push(c);
|
|
151
|
-
rest -= m;
|
|
152
|
-
if (rest === 0) {
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
rest /= acceptChars.length;
|
|
156
|
-
}
|
|
28
|
+
else if (htmlMatcher(file)) {
|
|
29
|
+
return 'html';
|
|
157
30
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return newClassName;
|
|
161
|
-
}
|
|
162
|
-
ignoreClassName(className) {
|
|
163
|
-
return regExpTest(this.opts.ignoreClass, className);
|
|
164
|
-
}
|
|
165
|
-
includeFilePath(filePath) {
|
|
166
|
-
const { include } = this.opts;
|
|
167
|
-
if (Array.isArray(include)) {
|
|
168
|
-
return regExpTest(include, filePath);
|
|
31
|
+
else if (jsMatcher(file)) {
|
|
32
|
+
return 'js';
|
|
169
33
|
}
|
|
170
34
|
else {
|
|
171
|
-
return
|
|
35
|
+
return 'other';
|
|
172
36
|
}
|
|
37
|
+
});
|
|
38
|
+
if (!groupedEntries.css) {
|
|
39
|
+
groupedEntries.css = [];
|
|
173
40
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (Array.isArray(exclude)) {
|
|
177
|
-
return regExpTest(exclude, filePath);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
41
|
+
if (!groupedEntries.html) {
|
|
42
|
+
groupedEntries.html = [];
|
|
182
43
|
}
|
|
183
|
-
|
|
184
|
-
|
|
44
|
+
if (!groupedEntries.js) {
|
|
45
|
+
groupedEntries.js = [];
|
|
185
46
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const cn = this.newClassMap[key];
|
|
189
|
-
if (cn)
|
|
190
|
-
return cn.name;
|
|
191
|
-
return className;
|
|
47
|
+
if (!groupedEntries.other) {
|
|
48
|
+
groupedEntries.other = [];
|
|
192
49
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return
|
|
199
|
-
let newClassName;
|
|
200
|
-
if (opts.customGenerate && typeof opts.customGenerate === 'function') {
|
|
201
|
-
newClassName = opts.customGenerate(original, opts, this.context);
|
|
202
|
-
}
|
|
203
|
-
if (!newClassName) {
|
|
204
|
-
newClassName = this.defaultClassGenerate();
|
|
205
|
-
}
|
|
206
|
-
if (opts.reserveClassName && regExpTest(opts.reserveClassName, newClassName)) {
|
|
207
|
-
if (opts.log) {
|
|
208
|
-
console.log(`The class name has been reserved. ${newClassName}`);
|
|
209
|
-
}
|
|
210
|
-
this.newClassSize++;
|
|
211
|
-
return this.generateClassName(original);
|
|
212
|
-
}
|
|
213
|
-
if (opts.log) {
|
|
214
|
-
console.log(`Minify class name from ${original} to ${newClassName}`);
|
|
215
|
-
}
|
|
216
|
-
const newClass = {
|
|
217
|
-
name: newClassName,
|
|
218
|
-
usedBy: []
|
|
50
|
+
return groupedEntries;
|
|
51
|
+
}
|
|
52
|
+
function createGlobMatcher(pattern, fallbackValue = false) {
|
|
53
|
+
if (typeof pattern === 'undefined') {
|
|
54
|
+
return function (file) {
|
|
55
|
+
return fallbackValue;
|
|
219
56
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return
|
|
57
|
+
}
|
|
58
|
+
return function (file) {
|
|
59
|
+
return isMatch(file, pattern);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function getCacheDir(basedir = process.cwd()) {
|
|
63
|
+
return path.resolve(basedir, 'node_modules/.cache', pluginName);
|
|
64
|
+
}
|
|
65
|
+
function mkCacheDirectory(cwd = process.cwd()) {
|
|
66
|
+
const cacheDirectory = getCacheDir(cwd);
|
|
67
|
+
const exists = fs.existsSync(cacheDirectory);
|
|
68
|
+
if (!exists) {
|
|
69
|
+
fs.mkdirSync(cacheDirectory, {
|
|
70
|
+
recursive: true
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return cacheDirectory;
|
|
74
|
+
}
|
|
75
|
+
function cacheDump(filename, data, basedir) {
|
|
76
|
+
try {
|
|
77
|
+
const dir = mkCacheDirectory(basedir);
|
|
78
|
+
fs.writeFileSync(path.resolve(dir, filename), JSON.stringify(Array.from(data), null, 2), 'utf-8');
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.log(error);
|
|
223
82
|
}
|
|
224
83
|
}
|
|
225
84
|
|
|
226
85
|
function getOptions(options = {}) {
|
|
227
86
|
const includeMatcher = createGlobMatcher(options.include, true);
|
|
228
87
|
const excludeMatcher = createGlobMatcher(options.exclude, false);
|
|
88
|
+
const currentMangleClassFilter = options.mangleClassFilter ?? defaultMangleClassFilter;
|
|
229
89
|
function isInclude(file) {
|
|
230
90
|
return includeMatcher(file) && !excludeMatcher(file);
|
|
231
91
|
}
|
|
@@ -252,7 +112,7 @@ function getOptions(options = {}) {
|
|
|
252
112
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
253
113
|
}
|
|
254
114
|
set.forEach((c) => {
|
|
255
|
-
if (!
|
|
115
|
+
if (!currentMangleClassFilter(c)) {
|
|
256
116
|
set.delete(c);
|
|
257
117
|
}
|
|
258
118
|
});
|
package/dist/loader/twm-css.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import ClassGenerator from '
|
|
2
|
+
import { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
3
3
|
export default function cssloader(this: webpack.LoaderContext<{
|
|
4
4
|
classGenerator: ClassGenerator;
|
|
5
5
|
getCachedClassSet: (() => Set<string>) | undefined;
|
package/dist/nuxt.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
|
-
require('./index-2edd594b.js');
|
|
6
|
-
require('@babel/types');
|
|
7
|
-
require('@babel/core');
|
|
8
5
|
require('micromatch');
|
|
9
6
|
require('fs');
|
|
10
7
|
require('path');
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('postcss');
|
|
14
|
-
require('postcss-selector-parser');
|
|
8
|
+
require('tailwindcss-mangle-shared');
|
|
9
|
+
require('tailwindcss-mangle-core');
|
|
15
10
|
require('tailwindcss-patch');
|
|
16
11
|
|
|
17
12
|
function nuxt (options = {}, nuxt) {
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { unplugin } from './index.mjs';
|
|
2
2
|
import 'unplugin';
|
|
3
|
-
import './index-92f879d3.mjs';
|
|
4
|
-
import '@babel/types';
|
|
5
|
-
import '@babel/core';
|
|
6
3
|
import 'micromatch';
|
|
7
4
|
import 'fs';
|
|
8
5
|
import 'path';
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
import 'postcss';
|
|
12
|
-
import 'postcss-selector-parser';
|
|
6
|
+
import 'tailwindcss-mangle-shared';
|
|
7
|
+
import 'tailwindcss-mangle-core';
|
|
13
8
|
import 'tailwindcss-patch';
|
|
14
9
|
|
|
15
10
|
function nuxt (options = {}, nuxt) {
|
package/dist/options.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Options, ClassSetOutputOptions, ClassMapOutputOptions } from './types';
|
|
2
2
|
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
3
|
-
import ClassGenerator from '
|
|
3
|
+
import { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
4
4
|
export declare function getOptions(options?: Options | undefined): {
|
|
5
5
|
getCachedClassSet: () => Set<string>;
|
|
6
6
|
classGenerator: ClassGenerator;
|
package/dist/rollup.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
|
-
require('./index-2edd594b.js');
|
|
6
|
-
require('@babel/types');
|
|
7
|
-
require('@babel/core');
|
|
8
5
|
require('micromatch');
|
|
9
6
|
require('fs');
|
|
10
7
|
require('path');
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('postcss');
|
|
14
|
-
require('postcss-selector-parser');
|
|
8
|
+
require('tailwindcss-mangle-shared');
|
|
9
|
+
require('tailwindcss-mangle-core');
|
|
15
10
|
require('tailwindcss-patch');
|
|
16
11
|
|
|
17
12
|
var rollup = index.unplugin.rollup;
|
package/dist/rollup.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { unplugin } from './index.mjs';
|
|
2
2
|
import 'unplugin';
|
|
3
|
-
import './index-92f879d3.mjs';
|
|
4
|
-
import '@babel/types';
|
|
5
|
-
import '@babel/core';
|
|
6
3
|
import 'micromatch';
|
|
7
4
|
import 'fs';
|
|
8
5
|
import 'path';
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
import 'postcss';
|
|
12
|
-
import 'postcss-selector-parser';
|
|
6
|
+
import 'tailwindcss-mangle-shared';
|
|
7
|
+
import 'tailwindcss-mangle-core';
|
|
13
8
|
import 'tailwindcss-patch';
|
|
14
9
|
|
|
15
10
|
var rollup = unplugin.rollup;
|
package/dist/twm-css.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('postcss');
|
|
5
|
-
require('postcss-selector-parser');
|
|
3
|
+
var tailwindcssMangleCore = require('tailwindcss-mangle-core');
|
|
6
4
|
|
|
7
5
|
function cssloader(content) {
|
|
8
6
|
this.cacheable && this.cacheable();
|
|
9
7
|
const opt = this.getOptions();
|
|
10
8
|
if (opt.getCachedClassSet) {
|
|
11
9
|
const runtimeSet = opt.getCachedClassSet();
|
|
12
|
-
return
|
|
10
|
+
return tailwindcssMangleCore.cssHandler(content, {
|
|
13
11
|
classGenerator: opt.classGenerator,
|
|
14
12
|
runtimeSet,
|
|
15
13
|
scene: 'loader'
|
package/dist/twm-css.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type ClassGenerator from '
|
|
2
|
-
export interface IClassGeneratorContextItem {
|
|
3
|
-
name: string;
|
|
4
|
-
usedBy: any[];
|
|
5
|
-
}
|
|
1
|
+
import type { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
6
2
|
export interface IClassGeneratorOptions {
|
|
7
3
|
reserveClassName?: (string | RegExp)[];
|
|
8
4
|
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined;
|
|
@@ -12,11 +8,6 @@ export interface IClassGeneratorOptions {
|
|
|
12
8
|
ignoreClass?: (string | RegExp)[];
|
|
13
9
|
classPrefix?: string;
|
|
14
10
|
}
|
|
15
|
-
export interface IClassGenerator {
|
|
16
|
-
newClassMap: Record<string, IClassGeneratorContextItem>;
|
|
17
|
-
newClassSize: number;
|
|
18
|
-
context: Record<string, any>;
|
|
19
|
-
}
|
|
20
11
|
export interface IHandlerOptions {
|
|
21
12
|
runtimeSet: Set<string>;
|
|
22
13
|
classGenerator: ClassGenerator;
|
|
@@ -34,6 +25,7 @@ export interface ClassMapOutputOptions {
|
|
|
34
25
|
dir?: string;
|
|
35
26
|
}
|
|
36
27
|
export interface Options {
|
|
28
|
+
mangleClassFilter?: (className: string) => boolean;
|
|
37
29
|
classGenerator?: IClassGeneratorOptions;
|
|
38
30
|
exclude?: string[];
|
|
39
31
|
include?: string[];
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
export declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
1
|
+
import { defaultMangleClassFilter, isMap, isRegexp } from 'tailwindcss-mangle-shared';
|
|
2
|
+
export { defaultMangleClassFilter, isMap, isRegexp };
|
|
4
3
|
export declare function getGroupedEntries<T>(entries: [string, T][], options?: {
|
|
5
4
|
cssMatcher(file: string): boolean;
|
|
6
5
|
htmlMatcher(file: string): boolean;
|
|
7
6
|
jsMatcher(file: string): boolean;
|
|
8
7
|
}): Record<"css" | "html" | "js" | "other", [string, T][]>;
|
|
9
|
-
export declare const acceptChars: string[];
|
|
10
|
-
export declare function stripEscapeSequence(words: string): string;
|
|
11
|
-
export declare const validate: (opts: IClassGeneratorOptions, classGenerator: IClassGenerator) => void;
|
|
12
|
-
export declare function isRegexp(value: unknown): boolean;
|
|
13
|
-
export declare function isMap(value: unknown): boolean;
|
|
14
|
-
export declare function regExpTest(arr: (string | RegExp)[] | undefined, str: string): boolean;
|
|
15
|
-
export declare function escapeStringRegexp(str: string): string;
|
|
16
8
|
export declare function createGlobMatcher(pattern: string | string[] | undefined, fallbackValue?: boolean): (file: string) => boolean;
|
|
17
9
|
export declare function getCacheDir(basedir?: string): string;
|
|
18
10
|
export declare function mkCacheDirectory(cwd?: string): string;
|
package/dist/vite.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
|
-
require('./index-2edd594b.js');
|
|
6
|
-
require('@babel/types');
|
|
7
|
-
require('@babel/core');
|
|
8
5
|
require('micromatch');
|
|
9
6
|
require('fs');
|
|
10
7
|
require('path');
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('postcss');
|
|
14
|
-
require('postcss-selector-parser');
|
|
8
|
+
require('tailwindcss-mangle-shared');
|
|
9
|
+
require('tailwindcss-mangle-core');
|
|
15
10
|
require('tailwindcss-patch');
|
|
16
11
|
|
|
17
12
|
var vite = index.unplugin.vite;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { unplugin } from './index.mjs';
|
|
2
2
|
import 'unplugin';
|
|
3
|
-
import './index-92f879d3.mjs';
|
|
4
|
-
import '@babel/types';
|
|
5
|
-
import '@babel/core';
|
|
6
3
|
import 'micromatch';
|
|
7
4
|
import 'fs';
|
|
8
5
|
import 'path';
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
import 'postcss';
|
|
12
|
-
import 'postcss-selector-parser';
|
|
6
|
+
import 'tailwindcss-mangle-shared';
|
|
7
|
+
import 'tailwindcss-mangle-core';
|
|
13
8
|
import 'tailwindcss-patch';
|
|
14
9
|
|
|
15
10
|
var vite = unplugin.vite;
|
package/dist/webpack.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
|
-
require('./index-2edd594b.js');
|
|
6
|
-
require('@babel/types');
|
|
7
|
-
require('@babel/core');
|
|
8
5
|
require('micromatch');
|
|
9
6
|
require('fs');
|
|
10
7
|
require('path');
|
|
11
|
-
require('
|
|
12
|
-
require('
|
|
13
|
-
require('postcss');
|
|
14
|
-
require('postcss-selector-parser');
|
|
8
|
+
require('tailwindcss-mangle-shared');
|
|
9
|
+
require('tailwindcss-mangle-core');
|
|
15
10
|
require('tailwindcss-patch');
|
|
16
11
|
|
|
17
12
|
var webpack = index.unplugin.webpack;
|
package/dist/webpack.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { unplugin } from './index.mjs';
|
|
2
2
|
import 'unplugin';
|
|
3
|
-
import './index-92f879d3.mjs';
|
|
4
|
-
import '@babel/types';
|
|
5
|
-
import '@babel/core';
|
|
6
3
|
import 'micromatch';
|
|
7
4
|
import 'fs';
|
|
8
5
|
import 'path';
|
|
9
|
-
import '
|
|
10
|
-
import '
|
|
11
|
-
import 'postcss';
|
|
12
|
-
import 'postcss-selector-parser';
|
|
6
|
+
import 'tailwindcss-mangle-shared';
|
|
7
|
+
import 'tailwindcss-mangle-core';
|
|
13
8
|
import 'tailwindcss-patch';
|
|
14
9
|
|
|
15
10
|
var webpack = unplugin.webpack;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-tailwindcss-mangle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -60,32 +60,23 @@
|
|
|
60
60
|
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@babel/core": "^7.21.5",
|
|
64
|
-
"@babel/types": "^7.21.5",
|
|
65
63
|
"micromatch": "^4.0.5",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"postcss-selector-parser": "^6.0.12",
|
|
69
|
-
"semver": "^7.5.0",
|
|
64
|
+
"tailwindcss-mangle-core": "^1.2.1",
|
|
65
|
+
"tailwindcss-patch": "^1.2.1",
|
|
70
66
|
"unplugin": "^1.3.1",
|
|
71
|
-
"tailwindcss-
|
|
67
|
+
"tailwindcss-mangle-shared": "^1.2.1"
|
|
72
68
|
},
|
|
73
69
|
"publishConfig": {
|
|
74
70
|
"access": "public",
|
|
75
71
|
"registry": "https://registry.npmjs.org/"
|
|
76
72
|
},
|
|
77
73
|
"devDependencies": {
|
|
78
|
-
"@parse5/tools": "^0.1.0",
|
|
79
|
-
"@types/babel__core": "^7.20.0",
|
|
80
|
-
"@types/escodegen": "^0.0.7",
|
|
81
74
|
"@types/micromatch": "^4.0.2",
|
|
82
|
-
"@types/semver": "^7.3.13",
|
|
83
|
-
"pkg-types": "^1.0.2",
|
|
84
75
|
"simple-functional-loader": "^1.2.1",
|
|
85
76
|
"tailwindcss": "^3.3.2",
|
|
86
77
|
"tslib": "^2.5.0",
|
|
87
|
-
"vite": "^4.3.
|
|
88
|
-
"webpack": "^5.
|
|
78
|
+
"vite": "^4.3.5",
|
|
79
|
+
"webpack": "^5.82.1"
|
|
89
80
|
},
|
|
90
81
|
"homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
|
|
91
82
|
"repository": {
|
|
@@ -97,7 +88,7 @@
|
|
|
97
88
|
"build": "cross-env NODE_ENV=production rollup -c",
|
|
98
89
|
"dev:tsc": "tsc -p tsconfig.json --sourceMap",
|
|
99
90
|
"build:tsc": "tsc -p tsconfig.json",
|
|
100
|
-
"
|
|
91
|
+
"_test": "jest",
|
|
101
92
|
"_prepare": "tw-patch"
|
|
102
93
|
}
|
|
103
94
|
}
|
package/dist/classGenerator.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IClassGeneratorOptions, IClassGeneratorContextItem, IClassGenerator } from './types';
|
|
2
|
-
declare class ClassGenerator implements IClassGenerator {
|
|
3
|
-
newClassMap: Record<string, IClassGeneratorContextItem>;
|
|
4
|
-
newClassSize: number;
|
|
5
|
-
context: Record<string, any>;
|
|
6
|
-
opts: IClassGeneratorOptions;
|
|
7
|
-
classPrefix: string;
|
|
8
|
-
constructor(opts?: IClassGeneratorOptions);
|
|
9
|
-
defaultClassGenerate(): string;
|
|
10
|
-
ignoreClassName(className: string): boolean;
|
|
11
|
-
includeFilePath(filePath: string): boolean;
|
|
12
|
-
excludeFilePath(filePath: string): boolean;
|
|
13
|
-
isFileIncluded(filePath: string): boolean;
|
|
14
|
-
transformCssClass(className: string): string;
|
|
15
|
-
generateClassName(original: string): IClassGeneratorContextItem;
|
|
16
|
-
}
|
|
17
|
-
export default ClassGenerator;
|
package/dist/css/index.d.ts
DELETED
package/dist/css/plugins.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ICssHandlerOptions } from '@/types';
|
|
2
|
-
import type { PluginCreator } from 'postcss';
|
|
3
|
-
export type PostcssMangleTailwindcssPlugin = PluginCreator<ICssHandlerOptions>;
|
|
4
|
-
declare const postcssMangleTailwindcssPlugin: PostcssMangleTailwindcssPlugin;
|
|
5
|
-
export { postcssMangleTailwindcssPlugin };
|
package/dist/html/index.d.ts
DELETED