Skip to content

Commit 9cacdf4

Browse files
authored
fix: docs and require preset-typescript (#38)
1 parent a807c0b commit 9cacdf4

File tree

4 files changed

+17
-39
lines changed

4 files changed

+17
-39
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tailwindcss-mangle/core",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "The core of tailwindcss-mangle",
55
"exports": {
66
".": {

packages/core/src/js/pre.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function preProcessJs(options: { code: string; replaceMap: Map<string, st
7373
presets: [
7474
// ['@babel/preset-react', {}],
7575
[
76-
'@babel/preset-typescript',
76+
require('@babel/preset-typescript'),
7777
{
7878
allExtensions: true,
7979
isTSX: true

packages/unplugin-tailwindcss-mangle/README.md

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ mangle tailwindcss utilities plugin
88
- [Features](#features)
99
- [Usage](#usage)
1010
- [1. Install Package](#1-install-package)
11-
- [2. Run patch script](#2-run-patch-script)
11+
- [2. Run install script](#2-run-install-script)
1212
- [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)
1515
- [vite](#vite)
1616
- [webpack](#webpack)
1717
- [Options](#options)
18-
- [classGenerator](#classgenerator)
19-
- [include / exclude](#include--exclude)
2018
- [Notice](#notice)
2119

2220
## Features
@@ -36,7 +34,7 @@ mangle tailwindcss utilities plugin
3634
<npm|yarn|pnpm> i -D unplugin-tailwindcss-mangle tailwindcss-patch
3735
```
3836

39-
### 2. Run patch script
37+
### 2. Run install script
4038

4139
```sh
4240
npx tw-patch install
@@ -50,25 +48,27 @@ npx tw-patch install
5048
},
5149
```
5250

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:
5454

5555
```sh
5656
npx tw-patch extract
5757
```
5858

5959
> See more options in [tailwindcss-patch](https://github.com/sonofmagic/tailwindcss-mangle/tree/main/packages/tailwindcss-patch)
6060
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`
6262

63-
### 5. register this plugin
63+
### 5. Register this plugin
6464

6565
#### vite
6666

6767
```js
6868
// for example: vue vite project
6969
import { defineConfig } from 'vite'
7070
import vue from '@vitejs/plugin-vue'
71-
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
71+
import utwm from 'unplugin-tailwindcss-mangle/vite'
7272
// https://vitejs.dev/config/
7373
export default defineConfig({
7474
plugins: [vue(), utwm()]
@@ -92,7 +92,7 @@ You will see all class was renamed to `tw-*`
9292
// esm
9393
import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
9494
// or cjs
95-
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
95+
const utwm = require('unplugin-tailwindcss-mangle/webpack')
9696
// use this webpack plugin
9797
// for example next.config.js
9898
const { defineConfig } = require('@vue/cli-service')
@@ -110,34 +110,12 @@ module.exports = defineConfig({
110110

111111
## Options
112112

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')
138114

139115
## Notice
140116

117+
By default, only the build will take effect. Due to some restrictions, it cannot take effect in the development mode.
118+
141119
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.
142120

143121
because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.

packages/unplugin-tailwindcss-mangle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unplugin-tailwindcss-mangle",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.mjs",

0 commit comments

Comments
 (0)