unplugin-tailwindcss-mangle 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/README.md +29 -36
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,22 +2,23 @@
2
2
 
3
3
  mangle tailwindcss utilities plugin
4
4
 
5
+ It is recommended to read the documentation of [tailwindcss-patch](https://github.com/sonofmagic/tailwindcss-mangle/tree/main/packages/tailwindcss-patch) first, `unplugin-tailwindcss-mangle` depends on this tool.
6
+
5
7
  > Now Support `vite` and `webpack`
6
8
 
7
9
  - [unplugin-tailwindcss-mangle](#unplugin-tailwindcss-mangle)
8
10
  - [Features](#features)
9
11
  - [Usage](#usage)
10
12
  - [1. Install Package](#1-install-package)
11
- - [2. Run patch script](#2-run-patch-script)
13
+ - [2. Run install script](#2-run-install-script)
12
14
  - [3. add `prepare` script in your `package.json`](#3-add-prepare-script-in-your-packagejson)
13
- - [4. run extract command](#4-run-extract-command)
14
- - [5. register this plugin](#5-register-this-plugin)
15
+ - [4. Run extract command](#4-run-extract-command)
16
+ - [5. Register this plugin](#5-register-this-plugin)
15
17
  - [vite](#vite)
16
18
  - [webpack](#webpack)
17
19
  - [Options](#options)
18
- - [classGenerator](#classgenerator)
19
- - [include / exclude](#include--exclude)
20
20
  - [Notice](#notice)
21
+ - [Migration form v1 to v2](#migration-form-v1-to-v2)
21
22
 
22
23
  ## Features
23
24
 
@@ -36,7 +37,7 @@ mangle tailwindcss utilities plugin
36
37
  <npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
37
38
  ```
38
39
 
39
- ### 2. Run patch script
40
+ ### 2. Run install script
40
41
 
41
42
  ```sh
42
43
  npx tw-patch install
@@ -50,7 +51,9 @@ npx tw-patch install
50
51
  },
51
52
  ```
52
53
 
53
- ### 4. run extract command
54
+ ### 4. Run extract command
55
+
56
+ cd to the same directory as `package.son` and `tailwind.config.js`, then run:
54
57
 
55
58
  ```sh
56
59
  npx tw-patch extract
@@ -58,9 +61,9 @@ npx tw-patch extract
58
61
 
59
62
  > See more options in [tailwindcss-patch](https://github.com/sonofmagic/tailwindcss-mangle/tree/main/packages/tailwindcss-patch)
60
63
 
61
- Then there will generate a json file: `.tw-patch/tw-class-list.json`
64
+ Then there will generate a json file: `.tw-patch/tw-class-list.json`
62
65
 
63
- ### 5. register this plugin
66
+ ### 5. Register this plugin
64
67
 
65
68
  #### vite
66
69
 
@@ -68,7 +71,7 @@ Then there will generate a json file: `.tw-patch/tw-class-list.json`
68
71
  // for example: vue vite project
69
72
  import { defineConfig } from 'vite'
70
73
  import vue from '@vitejs/plugin-vue'
71
- import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
74
+ import utwm from 'unplugin-tailwindcss-mangle/vite'
72
75
  // https://vitejs.dev/config/
73
76
  export default defineConfig({
74
77
  plugins: [vue(), utwm()]
@@ -92,7 +95,7 @@ You will see all class was renamed to `tw-*`
92
95
  // esm
93
96
  import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
94
97
  // or cjs
95
- const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
98
+ const utwm = require('unplugin-tailwindcss-mangle/webpack')
96
99
  // use this webpack plugin
97
100
  // for example next.config.js
98
101
  const { defineConfig } = require('@vue/cli-service')
@@ -110,34 +113,12 @@ module.exports = defineConfig({
110
113
 
111
114
  ## Options
112
115
 
113
- ### classGenerator
114
-
115
- custom class generator, if you want to custom class name (default 'tw-*'), use this options
116
-
117
- ```js
118
- export interface IClassGeneratorOptions {
119
- reserveClassName?: (string | RegExp)[]
120
- // custom generate class name
121
- customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined
122
- log?: boolean
123
- exclude?: (string | RegExp)[]
124
- include?: (string | RegExp)[]
125
- ignoreClass?: (string | RegExp)[]
126
- // default 'tw-',for example: tw-a,tw-b, you can set any you want, like '','ice-'
127
- classPrefix?: string
128
- }
129
- ```
130
-
131
- ### include / exclude
132
-
133
- Type: `string | string[]`
134
-
135
- Default: `undefined`
136
-
137
- `glob string` allow you to control the mangle range of bundles.
116
+ [types.ts]('./src/types.ts')
138
117
 
139
118
  ## Notice
140
119
 
120
+ By default, only the build will take effect. Due to some restrictions, it cannot take effect in the development mode.
121
+
141
122
  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.
142
123
 
143
124
  because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
@@ -150,3 +131,15 @@ document.body.innerHTML = innerHTML
150
131
  ```
151
132
 
152
133
  so only strings with `-` or `:` will be transformed.
134
+
135
+ ## Migration form v1 to v2
136
+
137
+ ```diff
138
+ // vite
139
+ - import { vitePlugin } from 'unplugin-tailwindcss-mangle'
140
+ + import utwm from 'unplugin-tailwindcss-mangle/vite'
141
+
142
+ // webpack
143
+ - import { webpackPlugin } from 'unplugin-tailwindcss-mangle'
144
+ + import utwm from 'unplugin-tailwindcss-mangle/webpack'
145
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -64,7 +64,7 @@
64
64
  "micromatch": "^4.0.5",
65
65
  "unplugin": "^1.4.0",
66
66
  "@tailwindcss-mangle/config": "^1.0.1",
67
- "@tailwindcss-mangle/core": "^2.0.0",
67
+ "@tailwindcss-mangle/core": "^2.0.2",
68
68
  "@tailwindcss-mangle/shared": "^2.0.0"
69
69
  },
70
70
  "publishConfig": {