unplugin-tailwindcss-mangle 3.0.0 → 3.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.
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ const core = require('@tailwindcss-mangle/core');
4
+
5
+ const TailwindcssMangleWebpackLoader = async function(source) {
6
+ const callback = this.async();
7
+ const { ctx } = this.getOptions();
8
+ const { code } = await core.cssHandler(source, {
9
+ ctx,
10
+ id: this.resource
11
+ });
12
+ callback(null, code);
13
+ };
14
+
15
+ module.exports = TailwindcssMangleWebpackLoader;
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,8 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Context } from '@tailwindcss-mangle/core';
3
+
4
+ declare const TailwindcssMangleWebpackLoader: (this: LoaderContext<{
5
+ ctx: Context;
6
+ }>, source: string) => Promise<void>;
7
+
8
+ export { TailwindcssMangleWebpackLoader as default };
@@ -0,0 +1,13 @@
1
+ import { cssHandler } from '@tailwindcss-mangle/core';
2
+
3
+ const TailwindcssMangleWebpackLoader = async function(source) {
4
+ const callback = this.async();
5
+ const { ctx } = this.getOptions();
6
+ const { code } = await cssHandler(source, {
7
+ ctx,
8
+ id: this.resource
9
+ });
10
+ callback(null, code);
11
+ };
12
+
13
+ export { TailwindcssMangleWebpackLoader as default };
package/dist/esbuild.cjs CHANGED
@@ -1,11 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ require('unplugin');
5
+ require('node:path');
4
6
  require('@tailwindcss-mangle/core');
5
7
  require('is-css-request');
6
8
  require('@rollup/pluginutils');
7
- require('unplugin');
8
- require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
12
+ require('@tailwindcss-mangle/shared');
9
13
 
10
14
  const esbuild = index.esbuild;
11
15
 
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
package/dist/esbuild.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => esbuild.Plugin;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => esbuild.Plugin;
5
5
 
6
6
  export { _default as default };
package/dist/esbuild.mjs CHANGED
@@ -1,9 +1,13 @@
1
1
  import unplugin from './index.mjs';
2
+ import 'unplugin';
3
+ import 'node:path';
2
4
  import '@tailwindcss-mangle/core';
3
5
  import 'is-css-request';
4
6
  import '@rollup/pluginutils';
5
- import 'unplugin';
6
- import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
10
+ import '@tailwindcss-mangle/shared';
7
11
 
8
12
  const esbuild = unplugin.esbuild;
9
13
 
package/dist/index.cjs CHANGED
@@ -1,18 +1,27 @@
1
1
  'use strict';
2
2
 
3
3
  const unplugin$1 = require('unplugin');
4
+ const path = require('node:path');
4
5
  const core = require('@tailwindcss-mangle/core');
5
6
  const isCssRequest = require('is-css-request');
6
7
  const pluginutils = require('@rollup/pluginutils');
7
- const constants = require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
8
+ const utils = require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
9
+ require('node:fs/promises');
10
+ require('node:process');
11
+ require('@tailwindcss-mangle/shared');
8
12
 
9
- const factory = (options) => {
13
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
14
+
15
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
16
+
17
+ const WEBPACK_LOADER = path__default.resolve(__dirname, "core/loader.cjs");
18
+ const factory = (options, { framework }) => {
10
19
  const ctx = new core.Context();
11
20
  let filter = (_id) => true;
12
21
  return [
13
22
  {
14
- name: `${constants.pluginName}:pre`,
15
- // enforce: 'pre',
23
+ name: `${utils.pluginName}:pre`,
24
+ enforce: "pre",
16
25
  async buildStart() {
17
26
  await ctx.initConfig({
18
27
  mangleOptions: options
@@ -21,7 +30,7 @@ const factory = (options) => {
21
30
  }
22
31
  },
23
32
  {
24
- name: `${constants.pluginName}`,
33
+ name: `${utils.pluginName}`,
25
34
  transformInclude(id) {
26
35
  return filter(id);
27
36
  },
@@ -43,16 +52,77 @@ const factory = (options) => {
43
52
  } else if (/\.html?/.test(id)) {
44
53
  return core.htmlHandler(code, opts);
45
54
  }
55
+ },
56
+ webpack(compiler) {
57
+ const { NormalModule } = compiler.webpack;
58
+ compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
59
+ NormalModule.getCompilationHooks(compilation).loader.tap(utils.pluginName, (_loaderContext, module) => {
60
+ {
61
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
62
+ if (idx > -1) {
63
+ module.loaders.splice(idx, 0, {
64
+ loader: WEBPACK_LOADER,
65
+ ident: null,
66
+ options: {
67
+ ctx
68
+ },
69
+ type: null
70
+ });
71
+ }
72
+ }
73
+ });
74
+ });
46
75
  }
47
76
  },
48
77
  {
49
- name: `${constants.pluginName}:post`,
78
+ name: `${utils.pluginName}:post`,
50
79
  enforce: "post",
51
80
  vite: {
52
81
  transformIndexHtml(html) {
53
82
  const { code } = core.htmlHandler(html, { ctx });
54
83
  return code;
55
84
  }
85
+ // generateBundle: {
86
+ // async handler(options, bundle) {
87
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
88
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
89
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
90
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
91
+ // const { code } = await cssHandler(cssSource.source.toString(), {
92
+ // id,
93
+ // ctx,
94
+ // })
95
+ // cssSource.source = code
96
+ // }
97
+ // }
98
+ // },
99
+ // },
100
+ },
101
+ webpack(compiler) {
102
+ const { Compilation, sources } = compiler.webpack;
103
+ const { ConcatSource } = sources;
104
+ compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
105
+ compilation.hooks.processAssets.tapPromise(
106
+ {
107
+ name: utils.pluginName,
108
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
109
+ },
110
+ async (assets) => {
111
+ const groupedEntries = utils.getGroupedEntries(Object.entries(assets));
112
+ if (groupedEntries.css.length > 0) {
113
+ for (let i = 0; i < groupedEntries.css.length; i++) {
114
+ const [id, cssSource] = groupedEntries.css[i];
115
+ const { code } = await core.cssHandler(cssSource.source().toString(), {
116
+ id,
117
+ ctx
118
+ });
119
+ const source = new ConcatSource(code);
120
+ compilation.updateAsset(id, source);
121
+ }
122
+ }
123
+ }
124
+ );
125
+ });
56
126
  },
57
127
  writeBundle() {
58
128
  ctx.dump();
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config_index.MangleUserConfig | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<_tailwindcss_mangle_config.MangleUserConfig | undefined, boolean>;
5
5
 
6
6
  export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,16 +1,30 @@
1
1
  import { createUnplugin } from 'unplugin';
2
+ import path from 'node:path';
2
3
  import { Context, jsHandler, cssHandler, htmlHandler } from '@tailwindcss-mangle/core';
3
4
  import { isCSSRequest } from 'is-css-request';
4
5
  import { createFilter } from '@rollup/pluginutils';
5
- import { p as pluginName } from './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
6
+ import { p as pluginName, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
7
+ import 'node:fs/promises';
8
+ import 'node:process';
9
+ import '@tailwindcss-mangle/shared';
6
10
 
7
- const factory = (options) => {
11
+
12
+
13
+ // -- Unbuild CommonJS Shims --
14
+ import __cjs_url__ from 'url';
15
+ import __cjs_path__ from 'path';
16
+ import __cjs_mod__ from 'module';
17
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
18
+ const __dirname = __cjs_path__.dirname(__filename);
19
+ const require = __cjs_mod__.createRequire(import.meta.url);
20
+ const WEBPACK_LOADER = path.resolve(__dirname, "core/loader.cjs");
21
+ const factory = (options, { framework }) => {
8
22
  const ctx = new Context();
9
23
  let filter = (_id) => true;
10
24
  return [
11
25
  {
12
26
  name: `${pluginName}:pre`,
13
- // enforce: 'pre',
27
+ enforce: "pre",
14
28
  async buildStart() {
15
29
  await ctx.initConfig({
16
30
  mangleOptions: options
@@ -41,6 +55,26 @@ const factory = (options) => {
41
55
  } else if (/\.html?/.test(id)) {
42
56
  return htmlHandler(code, opts);
43
57
  }
58
+ },
59
+ webpack(compiler) {
60
+ const { NormalModule } = compiler.webpack;
61
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
62
+ NormalModule.getCompilationHooks(compilation).loader.tap(pluginName, (_loaderContext, module) => {
63
+ {
64
+ const idx = module.loaders.findIndex((x) => x.loader.includes("postcss-loader"));
65
+ if (idx > -1) {
66
+ module.loaders.splice(idx, 0, {
67
+ loader: WEBPACK_LOADER,
68
+ ident: null,
69
+ options: {
70
+ ctx
71
+ },
72
+ type: null
73
+ });
74
+ }
75
+ }
76
+ });
77
+ });
44
78
  }
45
79
  },
46
80
  {
@@ -51,6 +85,47 @@ const factory = (options) => {
51
85
  const { code } = htmlHandler(html, { ctx });
52
86
  return code;
53
87
  }
88
+ // generateBundle: {
89
+ // async handler(options, bundle) {
90
+ // const groupedEntries = getGroupedEntries(Object.entries(bundle))
91
+ // if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
92
+ // for (let i = 0; i < groupedEntries.css.length; i++) {
93
+ // const [id, cssSource] = groupedEntries.css[i] as [string, OutputAsset]
94
+ // const { code } = await cssHandler(cssSource.source.toString(), {
95
+ // id,
96
+ // ctx,
97
+ // })
98
+ // cssSource.source = code
99
+ // }
100
+ // }
101
+ // },
102
+ // },
103
+ },
104
+ webpack(compiler) {
105
+ const { Compilation, sources } = compiler.webpack;
106
+ const { ConcatSource } = sources;
107
+ compiler.hooks.compilation.tap(pluginName, (compilation) => {
108
+ compilation.hooks.processAssets.tapPromise(
109
+ {
110
+ name: pluginName,
111
+ stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
112
+ },
113
+ async (assets) => {
114
+ const groupedEntries = getGroupedEntries(Object.entries(assets));
115
+ if (groupedEntries.css.length > 0) {
116
+ for (let i = 0; i < groupedEntries.css.length; i++) {
117
+ const [id, cssSource] = groupedEntries.css[i];
118
+ const { code } = await cssHandler(cssSource.source().toString(), {
119
+ id,
120
+ ctx
121
+ });
122
+ const source = new ConcatSource(code);
123
+ compilation.updateAsset(id, source);
124
+ }
125
+ }
126
+ }
127
+ );
128
+ });
54
129
  },
55
130
  writeBundle() {
56
131
  ctx.dump();
package/dist/rollup.cjs CHANGED
@@ -1,11 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ require('unplugin');
5
+ require('node:path');
4
6
  require('@tailwindcss-mangle/core');
5
7
  require('is-css-request');
6
8
  require('@rollup/pluginutils');
7
- require('unplugin');
8
- require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
12
+ require('@tailwindcss-mangle/shared');
9
13
 
10
14
  const rollup = index.rollup;
11
15
 
package/dist/rollup.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.mjs CHANGED
@@ -1,9 +1,13 @@
1
1
  import unplugin from './index.mjs';
2
+ import 'unplugin';
3
+ import 'node:path';
2
4
  import '@tailwindcss-mangle/core';
3
5
  import 'is-css-request';
4
6
  import '@rollup/pluginutils';
5
- import 'unplugin';
6
- import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
10
+ import '@tailwindcss-mangle/shared';
7
11
 
8
12
  const rollup = unplugin.rollup;
9
13
 
@@ -0,0 +1,64 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import process from 'node:process';
4
+ import { groupBy } from '@tailwindcss-mangle/shared';
5
+
6
+ const pluginName = "unplugin-tailwindcss-mangle";
7
+
8
+ function escapeStringRegexp(str) {
9
+ if (typeof str !== "string") {
10
+ throw new TypeError("Expected a string");
11
+ }
12
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
13
+ }
14
+ function getGroupedEntries(entries, options = {
15
+ cssMatcher(file) {
16
+ return /\.css$/.test(file);
17
+ },
18
+ htmlMatcher(file) {
19
+ return /\.html?$/.test(file);
20
+ },
21
+ jsMatcher(file) {
22
+ return /\.[cm]?js$/.test(file);
23
+ }
24
+ }) {
25
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
26
+ const groupedEntries = groupBy(entries, ([file]) => {
27
+ if (cssMatcher(file)) {
28
+ return "css";
29
+ } else if (htmlMatcher(file)) {
30
+ return "html";
31
+ } else if (jsMatcher(file)) {
32
+ return "js";
33
+ } else {
34
+ return "other";
35
+ }
36
+ });
37
+ if (!groupedEntries.css) {
38
+ groupedEntries.css = [];
39
+ }
40
+ if (!groupedEntries.html) {
41
+ groupedEntries.html = [];
42
+ }
43
+ if (!groupedEntries.js) {
44
+ groupedEntries.js = [];
45
+ }
46
+ if (!groupedEntries.other) {
47
+ groupedEntries.other = [];
48
+ }
49
+ return groupedEntries;
50
+ }
51
+ function getCacheDir(basedir = process.cwd()) {
52
+ return path.resolve(basedir, "node_modules/.cache", pluginName);
53
+ }
54
+ async function ensureDir(p) {
55
+ try {
56
+ await fs.access(p);
57
+ } catch {
58
+ await fs.mkdir(p, {
59
+ recursive: true
60
+ });
61
+ }
62
+ }
63
+
64
+ export { getCacheDir as a, ensureDir as b, escapeStringRegexp as e, getGroupedEntries as g, pluginName as p };
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs/promises');
4
+ const path = require('node:path');
5
+ const process = require('node:process');
6
+ const shared = require('@tailwindcss-mangle/shared');
7
+
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
+
10
+ const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
+ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
13
+
14
+ const pluginName = "unplugin-tailwindcss-mangle";
15
+
16
+ function escapeStringRegexp(str) {
17
+ if (typeof str !== "string") {
18
+ throw new TypeError("Expected a string");
19
+ }
20
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
21
+ }
22
+ function getGroupedEntries(entries, options = {
23
+ cssMatcher(file) {
24
+ return /\.css$/.test(file);
25
+ },
26
+ htmlMatcher(file) {
27
+ return /\.html?$/.test(file);
28
+ },
29
+ jsMatcher(file) {
30
+ return /\.[cm]?js$/.test(file);
31
+ }
32
+ }) {
33
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
34
+ const groupedEntries = shared.groupBy(entries, ([file]) => {
35
+ if (cssMatcher(file)) {
36
+ return "css";
37
+ } else if (htmlMatcher(file)) {
38
+ return "html";
39
+ } else if (jsMatcher(file)) {
40
+ return "js";
41
+ } else {
42
+ return "other";
43
+ }
44
+ });
45
+ if (!groupedEntries.css) {
46
+ groupedEntries.css = [];
47
+ }
48
+ if (!groupedEntries.html) {
49
+ groupedEntries.html = [];
50
+ }
51
+ if (!groupedEntries.js) {
52
+ groupedEntries.js = [];
53
+ }
54
+ if (!groupedEntries.other) {
55
+ groupedEntries.other = [];
56
+ }
57
+ return groupedEntries;
58
+ }
59
+ function getCacheDir(basedir = process__default.cwd()) {
60
+ return path__default.resolve(basedir, "node_modules/.cache", pluginName);
61
+ }
62
+ async function ensureDir(p) {
63
+ try {
64
+ await fs__default.access(p);
65
+ } catch {
66
+ await fs__default.mkdir(p, {
67
+ recursive: true
68
+ });
69
+ }
70
+ }
71
+
72
+ exports.ensureDir = ensureDir;
73
+ exports.escapeStringRegexp = escapeStringRegexp;
74
+ exports.getCacheDir = getCacheDir;
75
+ exports.getGroupedEntries = getGroupedEntries;
76
+ exports.pluginName = pluginName;
package/dist/utils.cjs CHANGED
@@ -1,77 +1,17 @@
1
1
  'use strict';
2
2
 
3
- const fs = require('node:fs/promises');
4
- const path = require('node:path');
5
- const process = require('node:process');
3
+ require('node:fs/promises');
4
+ require('node:path');
5
+ require('node:process');
6
6
  const shared = require('@tailwindcss-mangle/shared');
7
- const constants = require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
7
+ const utils = require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
8
8
 
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
9
 
11
- const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
13
- const process__default = /*#__PURE__*/_interopDefaultCompat(process);
14
-
15
- function escapeStringRegexp(str) {
16
- if (typeof str !== "string") {
17
- throw new TypeError("Expected a string");
18
- }
19
- return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
20
- }
21
- function getGroupedEntries(entries, options = {
22
- cssMatcher(file) {
23
- return /\.css$/.test(file);
24
- },
25
- htmlMatcher(file) {
26
- return /\.html?$/.test(file);
27
- },
28
- jsMatcher(file) {
29
- return /\.[cm]?js$/.test(file);
30
- }
31
- }) {
32
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
33
- const groupedEntries = shared.groupBy(entries, ([file]) => {
34
- if (cssMatcher(file)) {
35
- return "css";
36
- } else if (htmlMatcher(file)) {
37
- return "html";
38
- } else if (jsMatcher(file)) {
39
- return "js";
40
- } else {
41
- return "other";
42
- }
43
- });
44
- if (!groupedEntries.css) {
45
- groupedEntries.css = [];
46
- }
47
- if (!groupedEntries.html) {
48
- groupedEntries.html = [];
49
- }
50
- if (!groupedEntries.js) {
51
- groupedEntries.js = [];
52
- }
53
- if (!groupedEntries.other) {
54
- groupedEntries.other = [];
55
- }
56
- return groupedEntries;
57
- }
58
- function getCacheDir(basedir = process__default.cwd()) {
59
- return path__default.resolve(basedir, "node_modules/.cache", constants.pluginName);
60
- }
61
- async function ensureDir(p) {
62
- try {
63
- await fs__default.access(p);
64
- } catch {
65
- await fs__default.mkdir(p, {
66
- recursive: true
67
- });
68
- }
69
- }
70
10
 
71
11
  exports.defaultMangleClassFilter = shared.defaultMangleClassFilter;
72
12
  exports.isMap = shared.isMap;
73
13
  exports.isRegexp = shared.isRegexp;
74
- exports.ensureDir = ensureDir;
75
- exports.escapeStringRegexp = escapeStringRegexp;
76
- exports.getCacheDir = getCacheDir;
77
- exports.getGroupedEntries = getGroupedEntries;
14
+ exports.ensureDir = utils.ensureDir;
15
+ exports.escapeStringRegexp = utils.escapeStringRegexp;
16
+ exports.getCacheDir = utils.getCacheDir;
17
+ exports.getGroupedEntries = utils.getGroupedEntries;
package/dist/utils.mjs CHANGED
@@ -1,64 +1,5 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import process from 'node:process';
4
- import { groupBy } from '@tailwindcss-mangle/shared';
1
+ import 'node:fs/promises';
2
+ import 'node:path';
3
+ import 'node:process';
5
4
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
6
- import { p as pluginName } from './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
-
8
- function escapeStringRegexp(str) {
9
- if (typeof str !== "string") {
10
- throw new TypeError("Expected a string");
11
- }
12
- return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
13
- }
14
- function getGroupedEntries(entries, options = {
15
- cssMatcher(file) {
16
- return /\.css$/.test(file);
17
- },
18
- htmlMatcher(file) {
19
- return /\.html?$/.test(file);
20
- },
21
- jsMatcher(file) {
22
- return /\.[cm]?js$/.test(file);
23
- }
24
- }) {
25
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
26
- const groupedEntries = groupBy(entries, ([file]) => {
27
- if (cssMatcher(file)) {
28
- return "css";
29
- } else if (htmlMatcher(file)) {
30
- return "html";
31
- } else if (jsMatcher(file)) {
32
- return "js";
33
- } else {
34
- return "other";
35
- }
36
- });
37
- if (!groupedEntries.css) {
38
- groupedEntries.css = [];
39
- }
40
- if (!groupedEntries.html) {
41
- groupedEntries.html = [];
42
- }
43
- if (!groupedEntries.js) {
44
- groupedEntries.js = [];
45
- }
46
- if (!groupedEntries.other) {
47
- groupedEntries.other = [];
48
- }
49
- return groupedEntries;
50
- }
51
- function getCacheDir(basedir = process.cwd()) {
52
- return path.resolve(basedir, "node_modules/.cache", pluginName);
53
- }
54
- async function ensureDir(p) {
55
- try {
56
- await fs.access(p);
57
- } catch {
58
- await fs.mkdir(p, {
59
- recursive: true
60
- });
61
- }
62
- }
63
-
64
- export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
5
+ export { b as ensureDir, e as escapeStringRegexp, a as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
package/dist/vite.cjs CHANGED
@@ -1,11 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ require('unplugin');
5
+ require('node:path');
4
6
  require('@tailwindcss-mangle/core');
5
7
  require('is-css-request');
6
8
  require('@rollup/pluginutils');
7
- require('unplugin');
8
- require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
12
+ require('@tailwindcss-mangle/shared');
9
13
 
10
14
  const vite = index.vite;
11
15
 
package/dist/vite.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/vite.mjs CHANGED
@@ -1,9 +1,13 @@
1
1
  import unplugin from './index.mjs';
2
+ import 'unplugin';
3
+ import 'node:path';
2
4
  import '@tailwindcss-mangle/core';
3
5
  import 'is-css-request';
4
6
  import '@rollup/pluginutils';
5
- import 'unplugin';
6
- import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
10
+ import '@tailwindcss-mangle/shared';
7
11
 
8
12
  const vite = unplugin.vite;
9
13
 
package/dist/webpack.cjs CHANGED
@@ -1,11 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
+ require('unplugin');
5
+ require('node:path');
4
6
  require('@tailwindcss-mangle/core');
5
7
  require('is-css-request');
6
8
  require('@rollup/pluginutils');
7
- require('unplugin');
8
- require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
9
+ require('./shared/unplugin-tailwindcss-mangle.14c63525.cjs');
10
+ require('node:fs/promises');
11
+ require('node:process');
12
+ require('@tailwindcss-mangle/shared');
9
13
 
10
14
  const webpack = index.webpack;
11
15
 
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
package/dist/webpack.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
2
+ import * as _tailwindcss_mangle_config from '@tailwindcss-mangle/config';
3
3
 
4
- declare const _default: (options?: _tailwindcss_mangle_config_index.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options?: _tailwindcss_mangle_config.MangleUserConfig | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
6
  export { _default as default };
package/dist/webpack.mjs CHANGED
@@ -1,9 +1,13 @@
1
1
  import unplugin from './index.mjs';
2
+ import 'unplugin';
3
+ import 'node:path';
2
4
  import '@tailwindcss-mangle/core';
3
5
  import 'is-css-request';
4
6
  import '@rollup/pluginutils';
5
- import 'unplugin';
6
- import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
+ import './shared/unplugin-tailwindcss-mangle.077d08fc.mjs';
8
+ import 'node:fs/promises';
9
+ import 'node:process';
10
+ import '@tailwindcss-mangle/shared';
7
11
 
8
12
  const webpack = unplugin.webpack;
9
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "author": "SonOfMagic <qq1324318532@gmail.com>",
6
6
  "license": "MIT",
@@ -43,16 +43,6 @@
43
43
  "import": "./dist/esbuild.mjs",
44
44
  "require": "./dist/esbuild.cjs"
45
45
  },
46
- "./nuxt": {
47
- "types": "./dist/nuxt.d.ts",
48
- "import": "./dist/nuxt.mjs",
49
- "require": "./dist/nuxt.cjs"
50
- },
51
- "./utils": {
52
- "types": "./dist/utils.d.ts",
53
- "import": "./dist/utils.mjs",
54
- "require": "./dist/utils.cjs"
55
- },
56
46
  "./*": "./*"
57
47
  },
58
48
  "main": "./dist/index.cjs",
@@ -71,12 +61,12 @@
71
61
  ],
72
62
  "dependencies": {
73
63
  "@rollup/pluginutils": "^5.1.0",
74
- "is-css-request": "^1.0.0",
64
+ "is-css-request": "^1.0.1",
75
65
  "magic-string": "^0.30.10",
76
- "unplugin": "^1.10.1",
66
+ "unplugin": "^1.11.0",
67
+ "@tailwindcss-mangle/shared": "^3.0.0",
77
68
  "@tailwindcss-mangle/config": "^3.0.0",
78
- "@tailwindcss-mangle/core": "^3.0.0",
79
- "@tailwindcss-mangle/shared": "^3.0.0"
69
+ "@tailwindcss-mangle/core": "^3.0.0"
80
70
  },
81
71
  "publishConfig": {
82
72
  "access": "public",
@@ -84,7 +74,7 @@
84
74
  },
85
75
  "devDependencies": {
86
76
  "@types/babel__helper-plugin-utils": "^7.10.3",
87
- "astro": "^4.11.0",
77
+ "astro": "^4.11.5",
88
78
  "css-loader": "^7.1.2",
89
79
  "html-webpack-plugin": "^5.6.0",
90
80
  "mini-css-extract-plugin": "^2.9.0",
@@ -92,10 +82,10 @@
92
82
  "postcss": "^8.4.38",
93
83
  "postcss-loader": "^8.1.1",
94
84
  "tailwindcss": "^3.4.4",
95
- "vite": "^5.3.1",
96
- "webpack": "^5.92.1",
85
+ "vite": "^5.3.3",
86
+ "webpack": "^5.93.0",
97
87
  "webpack-build-utils": "^0.0.7",
98
- "tailwindcss-patch": "^3.0.1"
88
+ "tailwindcss-patch": "^3.0.2"
99
89
  },
100
90
  "scripts": {
101
91
  "dev": "unbuild --sourcemap",
package/dist/nuxt.cjs DELETED
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- const index = require('./index.cjs');
4
- require('@tailwindcss-mangle/core');
5
- require('is-css-request');
6
- require('@rollup/pluginutils');
7
- require('unplugin');
8
- require('./shared/unplugin-tailwindcss-mangle.462669b1.cjs');
9
-
10
- function nuxt(options = {}, nuxt) {
11
- nuxt.hook("webpack:config", (config) => {
12
- config.plugins = config.plugins || [];
13
- config.plugins.unshift(index.webpack(options));
14
- });
15
- nuxt.hook("vite:extendConfig", (config) => {
16
- config.plugins = config.plugins || [];
17
- config.plugins.push(index.vite(options));
18
- });
19
- }
20
-
21
- module.exports = nuxt;
package/dist/nuxt.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { MangleUserConfig } from '@tailwindcss-mangle/config';
2
-
3
- declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
4
-
5
- export { export_default as default };
package/dist/nuxt.mjs DELETED
@@ -1,19 +0,0 @@
1
- import unplugin from './index.mjs';
2
- import '@tailwindcss-mangle/core';
3
- import 'is-css-request';
4
- import '@rollup/pluginutils';
5
- import 'unplugin';
6
- import './shared/unplugin-tailwindcss-mangle.fdb82141.mjs';
7
-
8
- function nuxt(options = {}, nuxt) {
9
- nuxt.hook("webpack:config", (config) => {
10
- config.plugins = config.plugins || [];
11
- config.plugins.unshift(unplugin.webpack(options));
12
- });
13
- nuxt.hook("vite:extendConfig", (config) => {
14
- config.plugins = config.plugins || [];
15
- config.plugins.push(unplugin.vite(options));
16
- });
17
- }
18
-
19
- export { nuxt as default };
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const pluginName = "unplugin-tailwindcss-mangle";
4
-
5
- exports.pluginName = pluginName;
@@ -1,3 +0,0 @@
1
- const pluginName = "unplugin-tailwindcss-mangle";
2
-
3
- export { pluginName as p };