unplugin-tailwindcss-mangle 1.2.1 → 1.2.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/dist/index.d.ts +1 -0
- package/dist/index.js +18 -2
- package/dist/index.mjs +15 -2
- package/dist/options.d.ts +4 -0
- package/dist/types.d.ts +4 -4
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Options } from './types';
|
|
2
|
+
export { defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
2
3
|
export declare const unplugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
|
3
4
|
export declare const vitePlugin: (options?: Options | undefined) => import("vite").Plugin | import("vite").Plugin[];
|
|
4
5
|
export declare const webpackPlugin: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
|
package/dist/index.js
CHANGED
|
@@ -140,13 +140,16 @@ function getOptions(options = {}) {
|
|
|
140
140
|
isInclude,
|
|
141
141
|
classSetOutputOptions,
|
|
142
142
|
classMapOutputOptions,
|
|
143
|
-
twPatcher
|
|
143
|
+
twPatcher,
|
|
144
|
+
jsHandlerOptions: (options.jsHandlerOptions ?? {}),
|
|
145
|
+
htmlHandlerOptions: (options.htmlHandlerOptions ?? {}),
|
|
146
|
+
cssHandlerOptions: (options.cssHandlerOptions ?? {})
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
const outputCachedMap = new Map();
|
|
148
151
|
const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
149
|
-
const { classGenerator, getCachedClassSet, isInclude, classMapOutputOptions } = getOptions(options);
|
|
152
|
+
const { classGenerator, getCachedClassSet, isInclude, classMapOutputOptions, htmlHandlerOptions, jsHandlerOptions, cssHandlerOptions } = getOptions(options);
|
|
150
153
|
return {
|
|
151
154
|
name: pluginName,
|
|
152
155
|
enforce: 'post',
|
|
@@ -163,6 +166,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
163
166
|
const [file, asset] = groupedEntries.html[i];
|
|
164
167
|
if (isInclude(file)) {
|
|
165
168
|
asset.source = tailwindcssMangleCore.htmlHandler(asset.source.toString(), {
|
|
169
|
+
...htmlHandlerOptions,
|
|
166
170
|
classGenerator,
|
|
167
171
|
runtimeSet
|
|
168
172
|
});
|
|
@@ -174,6 +178,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
174
178
|
const [file, chunk] = groupedEntries.js[i];
|
|
175
179
|
if (isInclude(file)) {
|
|
176
180
|
const code = tailwindcssMangleCore.jsHandler(chunk.code, {
|
|
181
|
+
...jsHandlerOptions,
|
|
177
182
|
runtimeSet,
|
|
178
183
|
classGenerator
|
|
179
184
|
}).code;
|
|
@@ -188,6 +193,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
188
193
|
const [file, css] = groupedEntries.css[i];
|
|
189
194
|
if (isInclude(file)) {
|
|
190
195
|
css.source = tailwindcssMangleCore.cssHandler(css.source.toString(), {
|
|
196
|
+
...cssHandlerOptions,
|
|
191
197
|
classGenerator,
|
|
192
198
|
runtimeSet
|
|
193
199
|
});
|
|
@@ -265,6 +271,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
265
271
|
const [file, asset] = groupedEntries.html[i];
|
|
266
272
|
if (isInclude(file)) {
|
|
267
273
|
const html = tailwindcssMangleCore.htmlHandler(asset.source().toString(), {
|
|
274
|
+
...htmlHandlerOptions,
|
|
268
275
|
classGenerator,
|
|
269
276
|
runtimeSet
|
|
270
277
|
});
|
|
@@ -278,6 +285,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
278
285
|
const [file, chunk] = groupedEntries.js[i];
|
|
279
286
|
if (isInclude(file)) {
|
|
280
287
|
const code = tailwindcssMangleCore.jsHandler(chunk.source().toString(), {
|
|
288
|
+
...jsHandlerOptions,
|
|
281
289
|
runtimeSet,
|
|
282
290
|
classGenerator
|
|
283
291
|
}).code;
|
|
@@ -293,6 +301,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
293
301
|
const [file, css] = groupedEntries.css[i];
|
|
294
302
|
if (isInclude(file)) {
|
|
295
303
|
const newCss = tailwindcssMangleCore.cssHandler(css.source().toString(), {
|
|
304
|
+
...cssHandlerOptions,
|
|
296
305
|
classGenerator,
|
|
297
306
|
runtimeSet
|
|
298
307
|
});
|
|
@@ -306,6 +315,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
306
315
|
html.forEach((asset, file) => {
|
|
307
316
|
if (isInclude(file)) {
|
|
308
317
|
const html = tailwindcssMangleCore.htmlHandler(asset.source().toString(), {
|
|
318
|
+
...htmlHandlerOptions,
|
|
309
319
|
classGenerator,
|
|
310
320
|
runtimeSet
|
|
311
321
|
});
|
|
@@ -319,6 +329,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
319
329
|
if (isInclude(file)) {
|
|
320
330
|
const rawCode = chunk.source().toString();
|
|
321
331
|
const code = tailwindcssMangleCore.jsHandler(rawCode, {
|
|
332
|
+
...jsHandlerOptions,
|
|
322
333
|
runtimeSet,
|
|
323
334
|
classGenerator
|
|
324
335
|
}).code;
|
|
@@ -333,6 +344,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
333
344
|
css.forEach((style, file) => {
|
|
334
345
|
if (isInclude(file)) {
|
|
335
346
|
const newCss = tailwindcssMangleCore.cssHandler(style.source().toString(), {
|
|
347
|
+
...cssHandlerOptions,
|
|
336
348
|
classGenerator,
|
|
337
349
|
runtimeSet
|
|
338
350
|
});
|
|
@@ -358,6 +370,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
358
370
|
const vitePlugin = unplugin.vite;
|
|
359
371
|
const webpackPlugin = unplugin.webpack;
|
|
360
372
|
|
|
373
|
+
Object.defineProperty(exports, 'defaultMangleClassFilter', {
|
|
374
|
+
enumerable: true,
|
|
375
|
+
get: function () { return tailwindcssMangleShared.defaultMangleClassFilter; }
|
|
376
|
+
});
|
|
361
377
|
exports.unplugin = unplugin;
|
|
362
378
|
exports.vitePlugin = vitePlugin;
|
|
363
379
|
exports.webpackPlugin = webpackPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import micromatch from 'micromatch';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { groupBy, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
6
|
+
export { defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
6
7
|
import { ClassGenerator, htmlHandler, jsHandler, cssHandler } from 'tailwindcss-mangle-core';
|
|
7
8
|
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
8
9
|
|
|
@@ -130,13 +131,16 @@ function getOptions(options = {}) {
|
|
|
130
131
|
isInclude,
|
|
131
132
|
classSetOutputOptions,
|
|
132
133
|
classMapOutputOptions,
|
|
133
|
-
twPatcher
|
|
134
|
+
twPatcher,
|
|
135
|
+
jsHandlerOptions: (options.jsHandlerOptions ?? {}),
|
|
136
|
+
htmlHandlerOptions: (options.htmlHandlerOptions ?? {}),
|
|
137
|
+
cssHandlerOptions: (options.cssHandlerOptions ?? {})
|
|
134
138
|
};
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
const outputCachedMap = new Map();
|
|
138
142
|
const unplugin = createUnplugin((options = {}, meta) => {
|
|
139
|
-
const { classGenerator, getCachedClassSet, isInclude, classMapOutputOptions } = getOptions(options);
|
|
143
|
+
const { classGenerator, getCachedClassSet, isInclude, classMapOutputOptions, htmlHandlerOptions, jsHandlerOptions, cssHandlerOptions } = getOptions(options);
|
|
140
144
|
return {
|
|
141
145
|
name: pluginName,
|
|
142
146
|
enforce: 'post',
|
|
@@ -153,6 +157,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
153
157
|
const [file, asset] = groupedEntries.html[i];
|
|
154
158
|
if (isInclude(file)) {
|
|
155
159
|
asset.source = htmlHandler(asset.source.toString(), {
|
|
160
|
+
...htmlHandlerOptions,
|
|
156
161
|
classGenerator,
|
|
157
162
|
runtimeSet
|
|
158
163
|
});
|
|
@@ -164,6 +169,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
164
169
|
const [file, chunk] = groupedEntries.js[i];
|
|
165
170
|
if (isInclude(file)) {
|
|
166
171
|
const code = jsHandler(chunk.code, {
|
|
172
|
+
...jsHandlerOptions,
|
|
167
173
|
runtimeSet,
|
|
168
174
|
classGenerator
|
|
169
175
|
}).code;
|
|
@@ -178,6 +184,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
178
184
|
const [file, css] = groupedEntries.css[i];
|
|
179
185
|
if (isInclude(file)) {
|
|
180
186
|
css.source = cssHandler(css.source.toString(), {
|
|
187
|
+
...cssHandlerOptions,
|
|
181
188
|
classGenerator,
|
|
182
189
|
runtimeSet
|
|
183
190
|
});
|
|
@@ -255,6 +262,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
255
262
|
const [file, asset] = groupedEntries.html[i];
|
|
256
263
|
if (isInclude(file)) {
|
|
257
264
|
const html = htmlHandler(asset.source().toString(), {
|
|
265
|
+
...htmlHandlerOptions,
|
|
258
266
|
classGenerator,
|
|
259
267
|
runtimeSet
|
|
260
268
|
});
|
|
@@ -268,6 +276,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
268
276
|
const [file, chunk] = groupedEntries.js[i];
|
|
269
277
|
if (isInclude(file)) {
|
|
270
278
|
const code = jsHandler(chunk.source().toString(), {
|
|
279
|
+
...jsHandlerOptions,
|
|
271
280
|
runtimeSet,
|
|
272
281
|
classGenerator
|
|
273
282
|
}).code;
|
|
@@ -283,6 +292,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
283
292
|
const [file, css] = groupedEntries.css[i];
|
|
284
293
|
if (isInclude(file)) {
|
|
285
294
|
const newCss = cssHandler(css.source().toString(), {
|
|
295
|
+
...cssHandlerOptions,
|
|
286
296
|
classGenerator,
|
|
287
297
|
runtimeSet
|
|
288
298
|
});
|
|
@@ -296,6 +306,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
296
306
|
html.forEach((asset, file) => {
|
|
297
307
|
if (isInclude(file)) {
|
|
298
308
|
const html = htmlHandler(asset.source().toString(), {
|
|
309
|
+
...htmlHandlerOptions,
|
|
299
310
|
classGenerator,
|
|
300
311
|
runtimeSet
|
|
301
312
|
});
|
|
@@ -309,6 +320,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
309
320
|
if (isInclude(file)) {
|
|
310
321
|
const rawCode = chunk.source().toString();
|
|
311
322
|
const code = jsHandler(rawCode, {
|
|
323
|
+
...jsHandlerOptions,
|
|
312
324
|
runtimeSet,
|
|
313
325
|
classGenerator
|
|
314
326
|
}).code;
|
|
@@ -323,6 +335,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
323
335
|
css.forEach((style, file) => {
|
|
324
336
|
if (isInclude(file)) {
|
|
325
337
|
const newCss = cssHandler(style.source().toString(), {
|
|
338
|
+
...cssHandlerOptions,
|
|
326
339
|
classGenerator,
|
|
327
340
|
runtimeSet
|
|
328
341
|
});
|
package/dist/options.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Options, ClassSetOutputOptions, ClassMapOutputOptions } from './types';
|
|
2
2
|
import { TailwindcssPatcher } from 'tailwindcss-patch';
|
|
3
3
|
import { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
4
|
+
import type { IHtmlHandlerOptions, IJsHandlerOptions, ICssHandlerOptions } from 'tailwindcss-mangle-core';
|
|
4
5
|
export declare function getOptions(options?: Options | undefined): {
|
|
5
6
|
getCachedClassSet: () => Set<string>;
|
|
6
7
|
classGenerator: ClassGenerator;
|
|
@@ -10,4 +11,7 @@ export declare function getOptions(options?: Options | undefined): {
|
|
|
10
11
|
classSetOutputOptions: ClassSetOutputOptions;
|
|
11
12
|
classMapOutputOptions: ClassMapOutputOptions;
|
|
12
13
|
twPatcher: TailwindcssPatcher;
|
|
14
|
+
jsHandlerOptions: IJsHandlerOptions;
|
|
15
|
+
htmlHandlerOptions: IHtmlHandlerOptions;
|
|
16
|
+
cssHandlerOptions: ICssHandlerOptions;
|
|
13
17
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassGenerator } from 'tailwindcss-mangle-core';
|
|
1
|
+
import type { ClassGenerator, IHtmlHandlerOptions, IJsHandlerOptions, ICssHandlerOptions } from 'tailwindcss-mangle-core';
|
|
2
2
|
export interface IClassGeneratorOptions {
|
|
3
3
|
reserveClassName?: (string | RegExp)[];
|
|
4
4
|
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined;
|
|
@@ -12,9 +12,6 @@ export interface IHandlerOptions {
|
|
|
12
12
|
runtimeSet: Set<string>;
|
|
13
13
|
classGenerator: ClassGenerator;
|
|
14
14
|
}
|
|
15
|
-
export interface ICssHandlerOptions extends IHandlerOptions {
|
|
16
|
-
scene?: 'loader' | 'process';
|
|
17
|
-
}
|
|
18
15
|
export interface ClassSetOutputOptions {
|
|
19
16
|
filename: string;
|
|
20
17
|
dir?: string;
|
|
@@ -31,4 +28,7 @@ export interface Options {
|
|
|
31
28
|
include?: string[];
|
|
32
29
|
classSetOutput?: boolean | ClassSetOutputOptions;
|
|
33
30
|
classMapOutput?: boolean | ClassMapOutputOptions;
|
|
31
|
+
htmlHandlerOptions?: IHtmlHandlerOptions;
|
|
32
|
+
jsHandlerOptions?: IJsHandlerOptions;
|
|
33
|
+
cssHandlerOptions?: ICssHandlerOptions;
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-tailwindcss-mangle",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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,10 +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",
|
|
66
64
|
"unplugin": "^1.3.1",
|
|
67
|
-
"tailwindcss-mangle-
|
|
65
|
+
"tailwindcss-mangle-core": "^1.2.2",
|
|
66
|
+
"tailwindcss-mangle-shared": "^1.2.2",
|
|
67
|
+
"tailwindcss-patch": "^1.2.2"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"@types/micromatch": "^4.0.2",
|
|
75
75
|
"simple-functional-loader": "^1.2.1",
|
|
76
76
|
"tailwindcss": "^3.3.2",
|
|
77
|
-
"tslib": "^2.5.
|
|
78
|
-
"vite": "^4.3.
|
|
79
|
-
"webpack": "^5.
|
|
77
|
+
"tslib": "^2.5.3",
|
|
78
|
+
"vite": "^4.3.9",
|
|
79
|
+
"webpack": "^5.85.1"
|
|
80
80
|
},
|
|
81
81
|
"homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
|
|
82
82
|
"repository": {
|