unplugin-tailwindcss-mangle 0.1.4 → 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/dist/esbuild.js +1 -0
- package/dist/esbuild.mjs +1 -0
- package/dist/index.js +4 -26
- package/dist/index.mjs +3 -25
- package/dist/nuxt.js +1 -0
- package/dist/nuxt.mjs +1 -0
- package/dist/rollup.js +1 -0
- package/dist/rollup.mjs +1 -0
- package/dist/types.d.ts +1 -9
- package/dist/utils.d.ts +2 -10
- package/dist/vite.js +1 -0
- package/dist/vite.mjs +1 -0
- package/dist/webpack.js +1 -0
- package/dist/webpack.mjs +1 -0
- package/package.json +4 -3
package/dist/esbuild.js
CHANGED
package/dist/esbuild.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var unplugin$1 = require('unplugin');
|
|
|
6
6
|
var micromatch = require('micromatch');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var path = require('path');
|
|
9
|
+
var tailwindcssMangleShared = require('tailwindcss-mangle-shared');
|
|
9
10
|
var tailwindcssMangleCore = require('tailwindcss-mangle-core');
|
|
10
11
|
var tailwindcssPatch = require('tailwindcss-patch');
|
|
11
12
|
|
|
@@ -18,30 +19,6 @@ var path__default = /*#__PURE__*/_interopDefault(path);
|
|
|
18
19
|
const pluginName = 'unplugin-tailwindcss-mangle';
|
|
19
20
|
|
|
20
21
|
const { isMatch } = micromatch__default["default"];
|
|
21
|
-
const isMangleClass = (className) => {
|
|
22
|
-
return /[-:]/.test(className);
|
|
23
|
-
};
|
|
24
|
-
function groupBy(arr, cb) {
|
|
25
|
-
if (!Array.isArray(arr)) {
|
|
26
|
-
throw new Error('expected an array for first argument');
|
|
27
|
-
}
|
|
28
|
-
if (typeof cb !== 'function') {
|
|
29
|
-
throw new Error('expected a function for second argument');
|
|
30
|
-
}
|
|
31
|
-
const result = {};
|
|
32
|
-
for (let i = 0; i < arr.length; i++) {
|
|
33
|
-
const item = arr[i];
|
|
34
|
-
const bucketCategory = cb(item);
|
|
35
|
-
const bucket = result[bucketCategory];
|
|
36
|
-
if (!Array.isArray(bucket)) {
|
|
37
|
-
result[bucketCategory] = [item];
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
result[bucketCategory].push(item);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
22
|
function getGroupedEntries(entries, options = {
|
|
46
23
|
cssMatcher(file) {
|
|
47
24
|
return /\.css$/.test(file);
|
|
@@ -54,7 +31,7 @@ function getGroupedEntries(entries, options = {
|
|
|
54
31
|
}
|
|
55
32
|
}) {
|
|
56
33
|
const { cssMatcher, htmlMatcher, jsMatcher } = options;
|
|
57
|
-
const groupedEntries = groupBy(entries, ([file]) => {
|
|
34
|
+
const groupedEntries = tailwindcssMangleShared.groupBy(entries, ([file]) => {
|
|
58
35
|
if (cssMatcher(file)) {
|
|
59
36
|
return 'css';
|
|
60
37
|
}
|
|
@@ -118,6 +95,7 @@ function cacheDump(filename, data, basedir) {
|
|
|
118
95
|
function getOptions(options = {}) {
|
|
119
96
|
const includeMatcher = createGlobMatcher(options.include, true);
|
|
120
97
|
const excludeMatcher = createGlobMatcher(options.exclude, false);
|
|
98
|
+
const currentMangleClassFilter = options.mangleClassFilter ?? tailwindcssMangleShared.defaultMangleClassFilter;
|
|
121
99
|
function isInclude(file) {
|
|
122
100
|
return includeMatcher(file) && !excludeMatcher(file);
|
|
123
101
|
}
|
|
@@ -144,7 +122,7 @@ function getOptions(options = {}) {
|
|
|
144
122
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
145
123
|
}
|
|
146
124
|
set.forEach((c) => {
|
|
147
|
-
if (!
|
|
125
|
+
if (!currentMangleClassFilter(c)) {
|
|
148
126
|
set.delete(c);
|
|
149
127
|
}
|
|
150
128
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,36 +2,13 @@ import { createUnplugin } from 'unplugin';
|
|
|
2
2
|
import micromatch from 'micromatch';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { groupBy, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
5
6
|
import { ClassGenerator, htmlHandler, jsHandler, cssHandler } from 'tailwindcss-mangle-core';
|
|
6
7
|
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
7
8
|
|
|
8
9
|
const pluginName = 'unplugin-tailwindcss-mangle';
|
|
9
10
|
|
|
10
11
|
const { isMatch } = micromatch;
|
|
11
|
-
const isMangleClass = (className) => {
|
|
12
|
-
return /[-:]/.test(className);
|
|
13
|
-
};
|
|
14
|
-
function groupBy(arr, cb) {
|
|
15
|
-
if (!Array.isArray(arr)) {
|
|
16
|
-
throw new Error('expected an array for first argument');
|
|
17
|
-
}
|
|
18
|
-
if (typeof cb !== 'function') {
|
|
19
|
-
throw new Error('expected a function for second argument');
|
|
20
|
-
}
|
|
21
|
-
const result = {};
|
|
22
|
-
for (let i = 0; i < arr.length; i++) {
|
|
23
|
-
const item = arr[i];
|
|
24
|
-
const bucketCategory = cb(item);
|
|
25
|
-
const bucket = result[bucketCategory];
|
|
26
|
-
if (!Array.isArray(bucket)) {
|
|
27
|
-
result[bucketCategory] = [item];
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
result[bucketCategory].push(item);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
12
|
function getGroupedEntries(entries, options = {
|
|
36
13
|
cssMatcher(file) {
|
|
37
14
|
return /\.css$/.test(file);
|
|
@@ -108,6 +85,7 @@ function cacheDump(filename, data, basedir) {
|
|
|
108
85
|
function getOptions(options = {}) {
|
|
109
86
|
const includeMatcher = createGlobMatcher(options.include, true);
|
|
110
87
|
const excludeMatcher = createGlobMatcher(options.exclude, false);
|
|
88
|
+
const currentMangleClassFilter = options.mangleClassFilter ?? defaultMangleClassFilter;
|
|
111
89
|
function isInclude(file) {
|
|
112
90
|
return includeMatcher(file) && !excludeMatcher(file);
|
|
113
91
|
}
|
|
@@ -134,7 +112,7 @@ function getOptions(options = {}) {
|
|
|
134
112
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
135
113
|
}
|
|
136
114
|
set.forEach((c) => {
|
|
137
|
-
if (!
|
|
115
|
+
if (!currentMangleClassFilter(c)) {
|
|
138
116
|
set.delete(c);
|
|
139
117
|
}
|
|
140
118
|
});
|
package/dist/nuxt.js
CHANGED
package/dist/nuxt.mjs
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rollup.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
2
|
-
export interface IClassGeneratorContextItem {
|
|
3
|
-
name: string;
|
|
4
|
-
usedBy: any[];
|
|
5
|
-
}
|
|
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
package/dist/vite.mjs
CHANGED
package/dist/webpack.js
CHANGED
package/dist/webpack.mjs
CHANGED
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",
|
|
@@ -61,9 +61,10 @@
|
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"micromatch": "^4.0.5",
|
|
64
|
+
"tailwindcss-mangle-core": "^1.2.1",
|
|
65
|
+
"tailwindcss-patch": "^1.2.1",
|
|
64
66
|
"unplugin": "^1.3.1",
|
|
65
|
-
"tailwindcss-mangle-
|
|
66
|
-
"tailwindcss-patch": "^1.1.1"
|
|
67
|
+
"tailwindcss-mangle-shared": "^1.2.1"
|
|
67
68
|
},
|
|
68
69
|
"publishConfig": {
|
|
69
70
|
"access": "public",
|