Skip to content

Commit 8f4d3f4

Browse files
committed
chore: improve type but so valid in nextjs server mode
1 parent 52cfbca commit 8f4d3f4

File tree

12 files changed

+27
-21
lines changed

12 files changed

+27
-21
lines changed

apps/next-app/next.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const utwm = require('unplugin-tailwindcss-mangle')
1+
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
22
// import utwm from 'unplugin-tailwindcss-mangle'
33

44
/** @type {import('next').NextConfig} */
55
const nextConfig = {
66
reactStrictMode: true,
77
webpack: (config) => {
8-
config.plugins.push(utwm.webpack())
8+
config.plugins.push(utwm())
99
return config
1010
}
1111
}

apps/vite-react/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3-
import utwm from 'unplugin-tailwindcss-mangle'
3+
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
44
// https://vitejs.dev/config/
55
export default defineConfig({
6-
plugins: [react(), utwm.vite()]
6+
plugins: [react(), utwm()]
77
})

apps/vite-vue/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
import utwm from 'unplugin-tailwindcss-mangle'
3+
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
44
// https://vitejs.dev/config/
55
export default defineConfig({
6-
plugins: [vue(), utwm.vite()]
6+
plugins: [vue(), utwm()]
77
})

apps/webpack5-vue3/vue.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const { defineConfig } = require('@vue/cli-service')
2-
const utwm = require('unplugin-tailwindcss-mangle')
2+
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
33
module.exports = defineConfig({
44
transpileDependencies: true,
55
configureWebpack: (config) => {
6-
config.plugins.push(utwm.webpack())
6+
config.plugins.push(utwm)
77
}
88
})

packages/tailwindcss-patch/src/patcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { defu } from 'defu'
88
import { defaultOptions } from './defaults'
99
import { ensureFileContent, requireResolve } from './utils'
1010

11-
export function getInstalledPkgJsonPath(options: PatchOptions) {
11+
export function getInstalledPkgJsonPath(options: PatchOptions = {}) {
1212
try {
1313
// const cwd = process.cwd()
1414
const tmpJsonPath = requireResolve(`tailwindcss/package.json`, {

packages/unplugin-tailwindcss-mangle/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ npx tw-patch
5454
// for example: vue vite project
5555
import { defineConfig } from 'vite'
5656
import vue from '@vitejs/plugin-vue'
57-
import utwm from 'unplugin-tailwindcss-mangle'
57+
import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
5858
// https://vitejs.dev/config/
5959
export default defineConfig({
60-
plugins: [vue(), utwm.vite()]
60+
plugins: [vue(), utwm()]
6161
})
6262
```
6363

@@ -75,9 +75,12 @@ You will see all class was renamed to `tw-*`
7575
#### webpack
7676

7777
```js
78-
import utwm from 'unplugin-tailwindcss-mangle'
78+
// esm
79+
import { webpackPlugin as utwm } from 'unplugin-tailwindcss-mangle'
80+
// or cjs
81+
const { webpackPlugin: utwm } = require('unplugin-tailwindcss-mangle')
7982
// use this webpack plugin
80-
utwm.webpack()
83+
utwm()
8184
```
8285

8386
## Notice
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import unplugin from '.'
1+
import { unplugin } from '.'
22

33
export default unplugin.esbuild

packages/unplugin-tailwindcss-mangle/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { htmlHandler } from './html'
99
import { jsHandler } from './js'
1010
import { cssHandler } from './css'
1111
import type { } from 'webpack'
12-
const unplugin = createUnplugin((options: Options | undefined = {}, meta) => {
12+
export const unplugin = createUnplugin((options: Options | undefined = {}, meta) => {
1313

1414
const isMangleClass = (className: string) => {
1515
// ignore className like 'filter','container'
@@ -133,7 +133,10 @@ const unplugin = createUnplugin((options: Options | undefined = {}, meta) => {
133133
}
134134
}
135135
})
136-
export default unplugin
136+
137+
export const vitePlugin = unplugin.vite
138+
export const webpackPlugin = unplugin.webpack
139+
// export default unplugin
137140
// export const vitePlugin = unplugin.vite
138141
// export const rollupPlugin = unplugin.rollup
139142
// export const webpackPlugin = unplugin.webpack

packages/unplugin-tailwindcss-mangle/src/nuxt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Options } from './types'
2-
import unplugin from '.'
2+
import { unplugin } from '.'
33

44
export default function (options: Options = {}, nuxt: any) {
55
// install webpack plugin
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import unplugin from '.'
1+
import { unplugin } from '.'
22

33
export default unplugin.rollup

0 commit comments

Comments
 (0)