unplugin-tailwindcss-mangle 0.0.2 → 0.0.3
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 +99 -96
- package/dist/esbuild.js +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +7 -1
- package/dist/index.mjs +3 -1
- 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/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,99 @@
|
|
|
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
|
-
- [Notice](#notice)
|
|
17
|
-
|
|
18
|
-
## Features
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<!-- before -->
|
|
22
|
-
<div class="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex"></div>
|
|
23
|
-
<!-- after -->
|
|
24
|
-
<div class="tw-g tw-h tw-i tw-d tw-e tw-j tw-k tw-l"></div>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
### 1. Install Package
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
<npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2. Run patch script
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
npx tw-patch
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 3. add `prepare` script in your `package.json`
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
"scripts": {
|
|
45
|
-
"prepare": "tw-patch"
|
|
46
|
-
},
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 4. register this plugin
|
|
50
|
-
|
|
51
|
-
#### vite
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
// for example: vue vite project
|
|
55
|
-
import { defineConfig } from 'vite'
|
|
56
|
-
import vue from '@vitejs/plugin-vue'
|
|
57
|
-
import utwm from 'unplugin-tailwindcss-mangle'
|
|
58
|
-
// https://vitejs.dev/config/
|
|
59
|
-
export default defineConfig({
|
|
60
|
-
plugins: [vue(), utwm
|
|
61
|
-
})
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
then run script:
|
|
65
|
-
|
|
66
|
-
```sh
|
|
67
|
-
# generate bundle
|
|
68
|
-
yarn build
|
|
69
|
-
# preview
|
|
70
|
-
yarn preview
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
You will see all class was renamed to `tw-*`
|
|
74
|
-
|
|
75
|
-
#### webpack
|
|
76
|
-
|
|
77
|
-
```js
|
|
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
|
+
- [Notice](#notice)
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<!-- before -->
|
|
22
|
+
<div class="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex"></div>
|
|
23
|
+
<!-- after -->
|
|
24
|
+
<div class="tw-g tw-h tw-i tw-d tw-e tw-j tw-k tw-l"></div>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### 1. Install Package
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
<npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Run patch script
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npx tw-patch
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. add `prepare` script in your `package.json`
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prepare": "tw-patch"
|
|
46
|
+
},
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 4. register this plugin
|
|
50
|
+
|
|
51
|
+
#### vite
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
// for example: vue vite project
|
|
55
|
+
import { defineConfig } from 'vite'
|
|
56
|
+
import vue from '@vitejs/plugin-vue'
|
|
57
|
+
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
|
|
58
|
+
// https://vitejs.dev/config/
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
plugins: [vue(), utwm()]
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
then run script:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
# generate bundle
|
|
68
|
+
yarn build
|
|
69
|
+
# preview
|
|
70
|
+
yarn preview
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
You will see all class was renamed to `tw-*`
|
|
74
|
+
|
|
75
|
+
#### webpack
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
// esm
|
|
79
|
+
import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
|
|
80
|
+
// or cjs
|
|
81
|
+
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
|
|
82
|
+
// use this webpack plugin
|
|
83
|
+
utwm()
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Notice
|
|
87
|
+
|
|
88
|
+
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.
|
|
89
|
+
|
|
90
|
+
because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
|
|
91
|
+
|
|
92
|
+
it's dangerous to mangle some `js StringLiteral` like:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
const innerHTML = "i'm flex and relative and grid"
|
|
96
|
+
document.body.innerHTML = innerHTML
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
so only strings with `-` or `:` will be transformed.
|
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');
|
|
@@ -493,5 +495,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
493
495
|
}
|
|
494
496
|
};
|
|
495
497
|
});
|
|
498
|
+
const vitePlugin = unplugin.vite;
|
|
499
|
+
const webpackPlugin = unplugin.webpack;
|
|
496
500
|
|
|
497
|
-
|
|
501
|
+
exports.unplugin = unplugin;
|
|
502
|
+
exports.vitePlugin = vitePlugin;
|
|
503
|
+
exports.webpackPlugin = webpackPlugin;
|
package/dist/index.mjs
CHANGED
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/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.3",
|
|
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",
|