unplugin-tailwindcss-mangle 0.0.2 → 0.0.4
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 +121 -96
- package/dist/classGenerator.d.ts +6 -6
- package/dist/css/plugins.d.ts +2 -2
- package/dist/esbuild.js +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +38 -23
- package/dist/index.mjs +34 -23
- package/dist/js/index.d.ts +2 -0
- package/dist/nuxt.js +2 -2
- package/dist/nuxt.mjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/types.d.ts +7 -6
- package/dist/utils.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,96 +1,121 @@
|
|
|
1
|
-
# unplugin-tailwindcss-mangle
|
|
2
|
-
|
|
3
|
-
mangle tailwindcss utilities plugin
|
|
4
|
-
|
|
5
|
-
> Now Support `vite` and `webpack`
|
|
6
|
-
|
|
7
|
-
- [unplugin-tailwindcss-mangle](#unplugin-tailwindcss-mangle)
|
|
8
|
-
- [Features](#features)
|
|
9
|
-
- [Usage](#usage)
|
|
10
|
-
- [1. Install Package](#1-install-package)
|
|
11
|
-
- [2. Run patch script](#2-run-patch-script)
|
|
12
|
-
- [3. add `prepare` script in your `package.json`](#3-add-prepare-script-in-your-packagejson)
|
|
13
|
-
- [4. register this plugin](#4-register-this-plugin)
|
|
14
|
-
- [vite](#vite)
|
|
15
|
-
- [webpack](#webpack)
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<!--
|
|
24
|
-
<div class="
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
import
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#
|
|
70
|
-
yarn
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
# unplugin-tailwindcss-mangle
|
|
2
|
+
|
|
3
|
+
mangle tailwindcss utilities plugin
|
|
4
|
+
|
|
5
|
+
> Now Support `vite` and `webpack`
|
|
6
|
+
|
|
7
|
+
- [unplugin-tailwindcss-mangle](#unplugin-tailwindcss-mangle)
|
|
8
|
+
- [Features](#features)
|
|
9
|
+
- [Usage](#usage)
|
|
10
|
+
- [1. Install Package](#1-install-package)
|
|
11
|
+
- [2. Run patch script](#2-run-patch-script)
|
|
12
|
+
- [3. add `prepare` script in your `package.json`](#3-add-prepare-script-in-your-packagejson)
|
|
13
|
+
- [4. register this plugin](#4-register-this-plugin)
|
|
14
|
+
- [vite](#vite)
|
|
15
|
+
- [webpack](#webpack)
|
|
16
|
+
- [Options](#options)
|
|
17
|
+
- [classGenerator](#classgenerator)
|
|
18
|
+
- [Notice](#notice)
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!-- before -->
|
|
24
|
+
<div class="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex"></div>
|
|
25
|
+
<!-- after -->
|
|
26
|
+
<div class="tw-g tw-h tw-i tw-d tw-e tw-j tw-k tw-l"></div>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### 1. Install Package
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
<npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Run patch script
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx tw-patch
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. add `prepare` script in your `package.json`
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepare": "tw-patch"
|
|
48
|
+
},
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 4. register this plugin
|
|
52
|
+
|
|
53
|
+
#### vite
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
// for example: vue vite project
|
|
57
|
+
import { defineConfig } from 'vite'
|
|
58
|
+
import vue from '@vitejs/plugin-vue'
|
|
59
|
+
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
|
|
60
|
+
// https://vitejs.dev/config/
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
plugins: [vue(), utwm()]
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
then run script:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
# generate bundle
|
|
70
|
+
yarn build
|
|
71
|
+
# preview
|
|
72
|
+
yarn preview
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You will see all class was renamed to `tw-*`
|
|
76
|
+
|
|
77
|
+
#### webpack
|
|
78
|
+
|
|
79
|
+
> Experiment, not work right now
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
// esm
|
|
83
|
+
import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
|
|
84
|
+
// or cjs
|
|
85
|
+
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
|
|
86
|
+
// use this webpack plugin
|
|
87
|
+
utwm()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
### classGenerator
|
|
93
|
+
|
|
94
|
+
custom class generator, if you want to custom class name (default 'tw-*'), use this options
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
export interface IClassGeneratorOptions {
|
|
98
|
+
reserveClassName?: (string | RegExp)[]
|
|
99
|
+
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined
|
|
100
|
+
log?: boolean
|
|
101
|
+
exclude?: (string | RegExp)[]
|
|
102
|
+
include?: (string | RegExp)[]
|
|
103
|
+
ignoreClass?: (string | RegExp)[]
|
|
104
|
+
classPrefix?: string
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Notice
|
|
109
|
+
|
|
110
|
+
This plugin only transform those classes which name contain `-` or `:`, like `w-32`, `before:h-[300px]`,`after:dark:via-[#0141ff]/40`. some classes like `flex`,`relative` will not be mangled.
|
|
111
|
+
|
|
112
|
+
because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
|
|
113
|
+
|
|
114
|
+
it's dangerous to mangle some `js StringLiteral` like:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
const innerHTML = "i'm flex and relative and grid"
|
|
118
|
+
document.body.innerHTML = innerHTML
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
so only strings with `-` or `:` will be transformed.
|
package/dist/classGenerator.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IClassGeneratorOptions, IClassGeneratorContextItem, IClassGenerator } from './types';
|
|
2
2
|
declare class ClassGenerator implements IClassGenerator {
|
|
3
|
-
newClassMap: Record<string,
|
|
3
|
+
newClassMap: Record<string, IClassGeneratorContextItem>;
|
|
4
4
|
newClassSize: number;
|
|
5
5
|
context: Record<string, any>;
|
|
6
|
-
opts:
|
|
6
|
+
opts: IClassGeneratorOptions;
|
|
7
7
|
classPrefix: string;
|
|
8
|
-
constructor(opts?:
|
|
9
|
-
|
|
8
|
+
constructor(opts?: IClassGeneratorOptions);
|
|
9
|
+
defaultClassGenerate(): string;
|
|
10
10
|
ignoreClassName(className: string): boolean;
|
|
11
11
|
includeFilePath(filePath: string): boolean;
|
|
12
12
|
excludeFilePath(filePath: string): boolean;
|
|
13
13
|
isFileIncluded(filePath: string): boolean;
|
|
14
14
|
transformCssClass(className: string): string;
|
|
15
|
-
generateClassName(original: string):
|
|
15
|
+
generateClassName(original: string): IClassGeneratorContextItem;
|
|
16
16
|
}
|
|
17
17
|
export default ClassGenerator;
|
package/dist/css/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IClassGeneratorContextItem } from '@/types';
|
|
2
2
|
import type { PluginCreator } from 'postcss';
|
|
3
3
|
export type PostcssMangleTailwindcssPlugin = PluginCreator<{
|
|
4
|
-
newClassMap: Record<string,
|
|
4
|
+
newClassMap: Record<string, IClassGeneratorContextItem>;
|
|
5
5
|
}>;
|
|
6
6
|
declare const postcssMangleTailwindcssPlugin: PostcssMangleTailwindcssPlugin;
|
|
7
7
|
export { postcssMangleTailwindcssPlugin };
|
package/dist/esbuild.js
CHANGED
package/dist/esbuild.mjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Options } from './types';
|
|
2
|
-
declare const unplugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
|
3
|
-
export
|
|
2
|
+
export declare const unplugin: import("unplugin").UnpluginInstance<Options | undefined, boolean>;
|
|
3
|
+
export declare const vitePlugin: (options?: Options | undefined) => import("vite").Plugin | import("vite").Plugin[];
|
|
4
|
+
export declare const webpackPlugin: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var unplugin$1 = require('unplugin');
|
|
4
6
|
var tailwindcssPatch = require('tailwindcss-patch');
|
|
5
7
|
var parse5 = require('parse5');
|
|
@@ -110,7 +112,7 @@ class ClassGenerator {
|
|
|
110
112
|
this.opts = opts;
|
|
111
113
|
this.classPrefix = (_a = opts.classPrefix) !== null && _a !== void 0 ? _a : 'tw-';
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
defaultClassGenerate() {
|
|
114
116
|
const chars = [];
|
|
115
117
|
let rest = (this.newClassSize - (this.newClassSize % acceptChars.length)) / acceptChars.length;
|
|
116
118
|
if (rest > 0) {
|
|
@@ -168,11 +170,11 @@ class ClassGenerator {
|
|
|
168
170
|
if (cn)
|
|
169
171
|
return cn;
|
|
170
172
|
let newClassName;
|
|
171
|
-
if (opts.
|
|
172
|
-
newClassName = opts.
|
|
173
|
+
if (opts.customGenerate && typeof opts.customGenerate === 'function') {
|
|
174
|
+
newClassName = opts.customGenerate(original, opts, this.context);
|
|
173
175
|
}
|
|
174
176
|
if (!newClassName) {
|
|
175
|
-
newClassName = this.
|
|
177
|
+
newClassName = this.defaultClassGenerate();
|
|
176
178
|
}
|
|
177
179
|
if (opts.reserveClassName && regExpTest(opts.reserveClassName, newClassName)) {
|
|
178
180
|
if (opts.log) {
|
|
@@ -320,29 +322,38 @@ function getDefaultExportFromNamespaceIfPresent(n) {
|
|
|
320
322
|
}
|
|
321
323
|
const generate = getDefaultExportFromNamespaceIfPresent(_generate__default["default"]);
|
|
322
324
|
const traverse = getDefaultExportFromNamespaceIfPresent(_traverse__default["default"]);
|
|
323
|
-
function
|
|
324
|
-
const ast = parser.parse(rawSource);
|
|
325
|
+
function handleValue(str, node, options) {
|
|
325
326
|
const set = options.runtimeSet;
|
|
326
327
|
const clsGen = options.classGenerator;
|
|
328
|
+
const arr = splitCode(str);
|
|
329
|
+
let rawStr = str;
|
|
330
|
+
for (let i = 0; i < arr.length; i++) {
|
|
331
|
+
const v = arr[i];
|
|
332
|
+
if (set.has(v)) {
|
|
333
|
+
let ignoreFlag = false;
|
|
334
|
+
if (Array.isArray(node.leadingComments)) {
|
|
335
|
+
ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
|
|
336
|
+
}
|
|
337
|
+
if (!ignoreFlag) {
|
|
338
|
+
rawStr = rawStr.replace(new RegExp('(?<="|\\s)' + escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return rawStr;
|
|
343
|
+
}
|
|
344
|
+
function jsHandler(rawSource, options) {
|
|
345
|
+
const ast = parser.parse(rawSource);
|
|
327
346
|
const topt = {
|
|
328
347
|
StringLiteral: {
|
|
329
348
|
enter(p) {
|
|
330
349
|
const n = p.node;
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
ignoreFlag = n.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
|
|
339
|
-
}
|
|
340
|
-
if (!ignoreFlag) {
|
|
341
|
-
rawStr = rawStr.replace(new RegExp(escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
n.value = rawStr;
|
|
350
|
+
n.value = handleValue(n.value, n, options);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
TemplateElement: {
|
|
354
|
+
enter(p) {
|
|
355
|
+
const n = p.node;
|
|
356
|
+
n.value.raw = handleValue(n.value.raw, n, options);
|
|
346
357
|
}
|
|
347
358
|
},
|
|
348
359
|
noScope: true
|
|
@@ -390,7 +401,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
390
401
|
return /[-:]/.test(className);
|
|
391
402
|
};
|
|
392
403
|
let classSet;
|
|
393
|
-
const classGenerator = new ClassGenerator();
|
|
404
|
+
const classGenerator = new ClassGenerator(options.classGenerator);
|
|
394
405
|
function getCachedClassSet() {
|
|
395
406
|
const set = tailwindcssPatch.getClassCacheSet();
|
|
396
407
|
set.forEach((c) => {
|
|
@@ -493,5 +504,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
493
504
|
}
|
|
494
505
|
};
|
|
495
506
|
});
|
|
507
|
+
const vitePlugin = unplugin.vite;
|
|
508
|
+
const webpackPlugin = unplugin.webpack;
|
|
496
509
|
|
|
497
|
-
|
|
510
|
+
exports.unplugin = unplugin;
|
|
511
|
+
exports.vitePlugin = vitePlugin;
|
|
512
|
+
exports.webpackPlugin = webpackPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -101,7 +101,7 @@ class ClassGenerator {
|
|
|
101
101
|
this.opts = opts;
|
|
102
102
|
this.classPrefix = (_a = opts.classPrefix) !== null && _a !== void 0 ? _a : 'tw-';
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
defaultClassGenerate() {
|
|
105
105
|
const chars = [];
|
|
106
106
|
let rest = (this.newClassSize - (this.newClassSize % acceptChars.length)) / acceptChars.length;
|
|
107
107
|
if (rest > 0) {
|
|
@@ -159,11 +159,11 @@ class ClassGenerator {
|
|
|
159
159
|
if (cn)
|
|
160
160
|
return cn;
|
|
161
161
|
let newClassName;
|
|
162
|
-
if (opts.
|
|
163
|
-
newClassName = opts.
|
|
162
|
+
if (opts.customGenerate && typeof opts.customGenerate === 'function') {
|
|
163
|
+
newClassName = opts.customGenerate(original, opts, this.context);
|
|
164
164
|
}
|
|
165
165
|
if (!newClassName) {
|
|
166
|
-
newClassName = this.
|
|
166
|
+
newClassName = this.defaultClassGenerate();
|
|
167
167
|
}
|
|
168
168
|
if (opts.reserveClassName && regExpTest(opts.reserveClassName, newClassName)) {
|
|
169
169
|
if (opts.log) {
|
|
@@ -311,29 +311,38 @@ function getDefaultExportFromNamespaceIfPresent(n) {
|
|
|
311
311
|
}
|
|
312
312
|
const generate = getDefaultExportFromNamespaceIfPresent(_generate);
|
|
313
313
|
const traverse = getDefaultExportFromNamespaceIfPresent(_traverse);
|
|
314
|
-
function
|
|
315
|
-
const ast = parse$1(rawSource);
|
|
314
|
+
function handleValue(str, node, options) {
|
|
316
315
|
const set = options.runtimeSet;
|
|
317
316
|
const clsGen = options.classGenerator;
|
|
317
|
+
const arr = splitCode(str);
|
|
318
|
+
let rawStr = str;
|
|
319
|
+
for (let i = 0; i < arr.length; i++) {
|
|
320
|
+
const v = arr[i];
|
|
321
|
+
if (set.has(v)) {
|
|
322
|
+
let ignoreFlag = false;
|
|
323
|
+
if (Array.isArray(node.leadingComments)) {
|
|
324
|
+
ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
|
|
325
|
+
}
|
|
326
|
+
if (!ignoreFlag) {
|
|
327
|
+
rawStr = rawStr.replace(new RegExp('(?<="|\\s)' + escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return rawStr;
|
|
332
|
+
}
|
|
333
|
+
function jsHandler(rawSource, options) {
|
|
334
|
+
const ast = parse$1(rawSource);
|
|
318
335
|
const topt = {
|
|
319
336
|
StringLiteral: {
|
|
320
337
|
enter(p) {
|
|
321
338
|
const n = p.node;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
ignoreFlag = n.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
|
|
330
|
-
}
|
|
331
|
-
if (!ignoreFlag) {
|
|
332
|
-
rawStr = rawStr.replace(new RegExp(escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
n.value = rawStr;
|
|
339
|
+
n.value = handleValue(n.value, n, options);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
TemplateElement: {
|
|
343
|
+
enter(p) {
|
|
344
|
+
const n = p.node;
|
|
345
|
+
n.value.raw = handleValue(n.value.raw, n, options);
|
|
337
346
|
}
|
|
338
347
|
},
|
|
339
348
|
noScope: true
|
|
@@ -381,7 +390,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
381
390
|
return /[-:]/.test(className);
|
|
382
391
|
};
|
|
383
392
|
let classSet;
|
|
384
|
-
const classGenerator = new ClassGenerator();
|
|
393
|
+
const classGenerator = new ClassGenerator(options.classGenerator);
|
|
385
394
|
function getCachedClassSet() {
|
|
386
395
|
const set = getClassCacheSet();
|
|
387
396
|
set.forEach((c) => {
|
|
@@ -484,5 +493,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
484
493
|
}
|
|
485
494
|
};
|
|
486
495
|
});
|
|
496
|
+
const vitePlugin = unplugin.vite;
|
|
497
|
+
const webpackPlugin = unplugin.webpack;
|
|
487
498
|
|
|
488
|
-
export { unplugin
|
|
499
|
+
export { unplugin, vitePlugin, webpackPlugin };
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { StringLiteral, TemplateElement } from '@babel/types';
|
|
1
2
|
import type { IHandlerOptions } from '../types';
|
|
3
|
+
export declare function handleValue(str: string, node: StringLiteral | TemplateElement, options: IHandlerOptions): string;
|
|
2
4
|
export declare function jsHandler(rawSource: string, options: IHandlerOptions): import("@babel/generator").GeneratorResult;
|
package/dist/nuxt.js
CHANGED
|
@@ -38,11 +38,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
38
38
|
function nuxt (options = {}, nuxt) {
|
|
39
39
|
nuxt.hook('webpack:config', (config) => __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
config.plugins = config.plugins || [];
|
|
41
|
-
config.plugins.unshift(index.webpack(options));
|
|
41
|
+
config.plugins.unshift(index.unplugin.webpack(options));
|
|
42
42
|
}));
|
|
43
43
|
nuxt.hook('vite:extendConfig', (config) => __awaiter(this, void 0, void 0, function* () {
|
|
44
44
|
config.plugins = config.plugins || [];
|
|
45
|
-
config.plugins.push(index.vite(options));
|
|
45
|
+
config.plugins.push(index.unplugin.vite(options));
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
48
|
|
package/dist/nuxt.mjs
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rollup.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type ClassGenerator from './classGenerator';
|
|
2
|
-
export interface
|
|
3
|
-
}
|
|
4
|
-
export interface IMangleContextClass {
|
|
2
|
+
export interface IClassGeneratorContextItem {
|
|
5
3
|
name: string;
|
|
6
4
|
usedBy: any[];
|
|
7
5
|
}
|
|
8
|
-
export interface
|
|
6
|
+
export interface IClassGeneratorOptions {
|
|
9
7
|
reserveClassName?: (string | RegExp)[];
|
|
10
|
-
|
|
8
|
+
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined;
|
|
11
9
|
log?: boolean;
|
|
12
10
|
exclude?: (string | RegExp)[];
|
|
13
11
|
include?: (string | RegExp)[];
|
|
@@ -15,7 +13,7 @@ export interface IMangleOptions {
|
|
|
15
13
|
classPrefix?: string;
|
|
16
14
|
}
|
|
17
15
|
export interface IClassGenerator {
|
|
18
|
-
newClassMap: Record<string,
|
|
16
|
+
newClassMap: Record<string, IClassGeneratorContextItem>;
|
|
19
17
|
newClassSize: number;
|
|
20
18
|
context: Record<string, any>;
|
|
21
19
|
}
|
|
@@ -24,3 +22,6 @@ export interface IHandlerOptions {
|
|
|
24
22
|
runtimeSet: Set<string>;
|
|
25
23
|
classGenerator: ClassGenerator;
|
|
26
24
|
}
|
|
25
|
+
export interface Options {
|
|
26
|
+
classGenerator?: IClassGeneratorOptions;
|
|
27
|
+
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IClassGeneratorOptions, IClassGenerator } from './types';
|
|
2
2
|
export declare function groupBy<T>(arr: T[], cb: (arg: T) => string): Record<string, T[]>;
|
|
3
3
|
export declare function getGroupedEntries<T>(entries: [string, T][], options?: {
|
|
4
4
|
cssMatcher(file: string): boolean;
|
|
@@ -7,7 +7,7 @@ export declare function getGroupedEntries<T>(entries: [string, T][], options?: {
|
|
|
7
7
|
}): Record<"css" | "html" | "js" | "other", [string, T][]>;
|
|
8
8
|
export declare const acceptChars: string[];
|
|
9
9
|
export declare function stripEscapeSequence(words: string): string;
|
|
10
|
-
export declare const validate: (opts:
|
|
10
|
+
export declare const validate: (opts: IClassGeneratorOptions, classGenerator: IClassGenerator) => void;
|
|
11
11
|
export declare function isRegexp(value: unknown): boolean;
|
|
12
12
|
export declare function isMap(value: unknown): boolean;
|
|
13
13
|
export declare function regExpTest(arr: (string | RegExp)[] | undefined, str: string): boolean;
|
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": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "mangle tailwindcss utilities class",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"postcss-selector-parser": "^6.0.11",
|
|
65
65
|
"semver": "^7.5.0",
|
|
66
66
|
"unplugin": "^1.3.1",
|
|
67
|
-
"tailwindcss-patch": "1.0.
|
|
67
|
+
"tailwindcss-patch": "1.0.2"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public",
|