unplugin-tailwindcss-mangle 0.0.1 → 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
@@ -54,10 +54,10 @@ npx tw-patch
54
54
  // for example: vue vite project
55
55
  import { defineConfig } from 'vite'
56
56
  import vue from '@vitejs/plugin-vue'
57
- import utwm from 'unplugin-tailwindcss-mangle'
57
+ import { vitePlugin as utwm } from 'unplugin-tailwindcss-mangle'
58
58
  // https://vitejs.dev/config/
59
59
  export default defineConfig({
60
- plugins: [vue(), utwm.vite()]
60
+ plugins: [vue(), utwm()]
61
61
  })
62
62
  ```
63
63
 
@@ -75,14 +75,17 @@ You will see all class was renamed to `tw-*`
75
75
  #### webpack
76
76
 
77
77
  ```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')
79
82
  // use this webpack plugin
80
- utwm.webpack()
83
+ utwm()
81
84
  ```
82
85
 
83
86
  ## Notice
84
87
 
85
- This plugin only transform those classes which name with `-` or `:`, like `w-32`, `before:h-[300px]`,`after:dark:via-[#0141ff]/40`. some classes like `flex`,`relative` will not be mangled.
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.
86
89
 
87
90
  because plugin will **traverse** all `html class attr` and `js StringLiteral` to find `utilities` generated by `tailwindcss`.
88
91
 
package/dist/esbuild.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (options?: import("./types").Options | undefined) => import("unplugin").EsbuildPlugin;
1
+ declare const _default: (options?: import("./types").Options | undefined) => import("esbuild").Plugin;
2
2
  export default _default;
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');
@@ -386,7 +388,7 @@ function cssHandler(rawSource, options) {
386
388
  }
387
389
 
388
390
  const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
389
- const mangleClass = (className) => {
391
+ const isMangleClass = (className) => {
390
392
  return /[-:]/.test(className);
391
393
  };
392
394
  let classSet;
@@ -394,7 +396,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
394
396
  function getCachedClassSet() {
395
397
  const set = tailwindcssPatch.getClassCacheSet();
396
398
  set.forEach((c) => {
397
- if (!mangleClass(c)) {
399
+ if (!isMangleClass(c)) {
398
400
  set.delete(c);
399
401
  }
400
402
  });
@@ -408,6 +410,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
408
410
  generateBundle: {
409
411
  handler(options, bundle, isWrite) {
410
412
  const runtimeSet = getCachedClassSet();
413
+ if (!runtimeSet.size) {
414
+ return;
415
+ }
411
416
  const groupedEntries = getGroupedEntries(Object.entries(bundle));
412
417
  if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
413
418
  for (let i = 0; i < groupedEntries.html.length; i++) {
@@ -448,6 +453,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
448
453
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
449
454
  }, (assets) => {
450
455
  const runtimeSet = getCachedClassSet();
456
+ if (!runtimeSet.size) {
457
+ return;
458
+ }
451
459
  const groupedEntries = getGroupedEntries(Object.entries(assets));
452
460
  if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
453
461
  for (let i = 0; i < groupedEntries.html.length; i++) {
@@ -487,5 +495,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
487
495
  }
488
496
  };
489
497
  });
498
+ const vitePlugin = unplugin.vite;
499
+ const webpackPlugin = unplugin.webpack;
490
500
 
491
- module.exports = unplugin;
501
+ exports.unplugin = unplugin;
502
+ exports.vitePlugin = vitePlugin;
503
+ exports.webpackPlugin = webpackPlugin;
package/dist/index.mjs CHANGED
@@ -377,7 +377,7 @@ function cssHandler(rawSource, options) {
377
377
  }
378
378
 
379
379
  const unplugin = createUnplugin((options = {}, meta) => {
380
- const mangleClass = (className) => {
380
+ const isMangleClass = (className) => {
381
381
  return /[-:]/.test(className);
382
382
  };
383
383
  let classSet;
@@ -385,7 +385,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
385
385
  function getCachedClassSet() {
386
386
  const set = getClassCacheSet();
387
387
  set.forEach((c) => {
388
- if (!mangleClass(c)) {
388
+ if (!isMangleClass(c)) {
389
389
  set.delete(c);
390
390
  }
391
391
  });
@@ -399,6 +399,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
399
399
  generateBundle: {
400
400
  handler(options, bundle, isWrite) {
401
401
  const runtimeSet = getCachedClassSet();
402
+ if (!runtimeSet.size) {
403
+ return;
404
+ }
402
405
  const groupedEntries = getGroupedEntries(Object.entries(bundle));
403
406
  if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
404
407
  for (let i = 0; i < groupedEntries.html.length; i++) {
@@ -439,6 +442,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
439
442
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
440
443
  }, (assets) => {
441
444
  const runtimeSet = getCachedClassSet();
445
+ if (!runtimeSet.size) {
446
+ return;
447
+ }
442
448
  const groupedEntries = getGroupedEntries(Object.entries(assets));
443
449
  if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
444
450
  for (let i = 0; i < groupedEntries.html.length; i++) {
@@ -478,5 +484,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
478
484
  }
479
485
  };
480
486
  });
487
+ const vitePlugin = unplugin.vite;
488
+ const webpackPlugin = unplugin.webpack;
481
489
 
482
- 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.1",
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.0"
67
+ "tailwindcss-patch": "1.0.2"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public",