unplugin-tailwindcss-mangle 2.0.0 → 2.0.1

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 +14 -36
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -8,15 +8,13 @@ mangle tailwindcss utilities plugin
8
8
  - [Features](#features)
9
9
  - [Usage](#usage)
10
10
  - [1. Install Package](#1-install-package)
11
- - [2. Run patch script](#2-run-patch-script)
11
+ - [2. Run install script](#2-run-install-script)
12
12
  - [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)
13
+ - [4. Run extract command](#4-run-extract-command)
14
+ - [5. Register this plugin](#5-register-this-plugin)
15
15
  - [vite](#vite)
16
16
  - [webpack](#webpack)
17
17
  - [Options](#options)
18
- - [classGenerator](#classgenerator)
19
- - [include / exclude](#include--exclude)
20
18
  - [Notice](#notice)
21
19
 
22
20
  ## Features
@@ -36,7 +34,7 @@ mangle tailwindcss utilities plugin
36
34
  <npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
37
35
  ```
38
36
 
39
- ### 2. Run patch script
37
+ ### 2. Run install script
40
38
 
41
39
  ```sh
42
40
  npx tw-patch install
@@ -50,7 +48,9 @@ npx tw-patch install
50
48
  },
51
49
  ```
52
50
 
53
- ### 4. run extract command
51
+ ### 4. Run extract command
52
+
53
+ cd to the same directory as `package.son` and `tailwind.config.js`, then run:
54
54
 
55
55
  ```sh
56
56
  npx tw-patch extract
@@ -58,9 +58,9 @@ npx tw-patch extract
58
58
 
59
59
  > See more options in [tailwindcss-patch](https://github.com/sonofmagic/tailwindcss-mangle/tree/main/packages/tailwindcss-patch)
60
60
 
61
- Then there will generate a json file: `.tw-patch/tw-class-list.json`
61
+ Then there will generate a json file: `.tw-patch/tw-class-list.json`
62
62
 
63
- ### 5. register this plugin
63
+ ### 5. Register this plugin
64
64
 
65
65
  #### vite
66
66
 
@@ -68,7 +68,7 @@ Then there will generate a json file: `.tw-patch/tw-class-list.json`
68
68
  // for example: vue vite project
69
69
  import { defineConfig } from 'vite'
70
70
  import vue from '@vitejs/plugin-vue'
71
- import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
71
+ import utwm from 'unplugin-tailwindcss-mangle/vite'
72
72
  // https://vitejs.dev/config/
73
73
  export default defineConfig({
74
74
  plugins: [vue(), utwm()]
@@ -92,7 +92,7 @@ You will see all class was renamed to `tw-*`
92
92
  // esm
93
93
  import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
94
94
  // or cjs
95
- const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
95
+ const utwm = require('unplugin-tailwindcss-mangle/webpack')
96
96
  // use this webpack plugin
97
97
  // for example next.config.js
98
98
  const { defineConfig } = require('@vue/cli-service')
@@ -110,34 +110,12 @@ module.exports = defineConfig({
110
110
 
111
111
  ## Options
112
112
 
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.
113
+ [types.ts]('./src/types.ts')
138
114
 
139
115
  ## Notice
140
116
 
117
+ By default, only the build will take effect. Due to some restrictions, it cannot take effect in the development mode.
118
+
141
119
  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
120
 
143
121
  because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
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.1",
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.1",
68
68
  "@tailwindcss-mangle/shared": "^2.0.0"
69
69
  },
70
70
  "publishConfig": {