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 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.vite()]
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
- import utwm from 'unplugin-tailwindcss-mangle'
79
- // use this webpack plugin
80
- utwm.webpack()
81
- ```
82
-
83
- ## Notice
84
-
85
- 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.
86
-
87
- because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
88
-
89
- it's dangerous to mangle some `js StringLiteral` like:
90
-
91
- ```js
92
- const innerHTML = "i'm flex and relative and grid"
93
- document.body.innerHTML = innerHTML
94
- ```
95
-
96
- so only strings with `-` or `:` will be transformed.
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
@@ -10,6 +10,6 @@ require('@babel/traverse');
10
10
  require('postcss');
11
11
  require('postcss-selector-parser');
12
12
 
13
- var esbuild = index.esbuild;
13
+ var esbuild = index.unplugin.esbuild;
14
14
 
15
15
  module.exports = esbuild;
package/dist/esbuild.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import unplugin from './index.mjs';
1
+ import { unplugin } from './index.mjs';
2
2
  import 'unplugin';
3
3
  import 'tailwindcss-patch';
4
4
  import 'parse5';
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 default unplugin;
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
- module.exports = unplugin;
501
+ exports.unplugin = unplugin;
502
+ exports.vitePlugin = vitePlugin;
503
+ exports.webpackPlugin = webpackPlugin;
package/dist/index.mjs CHANGED
@@ -484,5 +484,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
484
484
  }
485
485
  };
486
486
  });
487
+ const vitePlugin = unplugin.vite;
488
+ const webpackPlugin = unplugin.webpack;
487
489
 
488
- export { unplugin as default };
490
+ export { unplugin, vitePlugin, webpackPlugin };
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
@@ -1,4 +1,4 @@
1
- import unplugin from './index.mjs';
1
+ import { unplugin } from './index.mjs';
2
2
  import 'unplugin';
3
3
  import 'tailwindcss-patch';
4
4
  import 'parse5';
package/dist/rollup.js CHANGED
@@ -10,6 +10,6 @@ require('@babel/traverse');
10
10
  require('postcss');
11
11
  require('postcss-selector-parser');
12
12
 
13
- var rollup = index.rollup;
13
+ var rollup = index.unplugin.rollup;
14
14
 
15
15
  module.exports = rollup;
package/dist/rollup.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import unplugin from './index.mjs';
1
+ import { unplugin } from './index.mjs';
2
2
  import 'unplugin';
3
3
  import 'tailwindcss-patch';
4
4
  import 'parse5';
package/dist/vite.js CHANGED
@@ -10,6 +10,6 @@ require('@babel/traverse');
10
10
  require('postcss');
11
11
  require('postcss-selector-parser');
12
12
 
13
- var vite = index.vite;
13
+ var vite = index.unplugin.vite;
14
14
 
15
15
  module.exports = vite;
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import unplugin from './index.mjs';
1
+ import { unplugin } from './index.mjs';
2
2
  import 'unplugin';
3
3
  import 'tailwindcss-patch';
4
4
  import 'parse5';
package/dist/webpack.js CHANGED
@@ -10,6 +10,6 @@ require('@babel/traverse');
10
10
  require('postcss');
11
11
  require('postcss-selector-parser');
12
12
 
13
- var webpack = index.webpack;
13
+ var webpack = index.unplugin.webpack;
14
14
 
15
15
  module.exports = webpack;
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import unplugin from './index.mjs';
1
+ import { unplugin } from './index.mjs';
2
2
  import 'unplugin';
3
3
  import 'tailwindcss-patch';
4
4
  import 'parse5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "0.0.2",
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.1"
67
+ "tailwindcss-patch": "1.0.2"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public",