unplugin-tailwindcss-mangle 2.0.6 → 2.2.0

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/dist/esbuild.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
5
  require('node:fs/promises');
10
- require('micromatch');
11
6
  require('unplugin');
12
7
  require('@tailwindcss-mangle/core');
13
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+ require('magic-string');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
14
11
 
15
12
  const esbuild = index.esbuild;
16
13
 
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => esbuild.Plugin;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as esbuild from 'esbuild';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => esbuild.Plugin;
5
+
6
+ export { _default as default };
package/dist/esbuild.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
3
  import 'node:fs/promises';
8
- import 'micromatch';
9
4
  import 'unplugin';
10
5
  import '@tailwindcss-mangle/core';
11
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
6
+ import 'magic-string';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
12
9
 
13
10
  const esbuild = unplugin.esbuild;
14
11
 
package/dist/index.cjs CHANGED
@@ -1,153 +1,45 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('node:path');
4
- const fs$1 = require('node:fs/promises');
4
+ const fs = require('node:fs/promises');
5
5
  const unplugin$1 = require('unplugin');
6
6
  const core = require('@tailwindcss-mangle/core');
7
- const fs = require('node:fs');
8
- const shared = require('@tailwindcss-mangle/shared');
9
- const config = require('@tailwindcss-mangle/config');
10
- const fastSort = require('fast-sort');
11
- const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
- require('micromatch');
7
+ const MagicString = require('magic-string');
8
+ const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
9
+ require('@tailwindcss-mangle/shared');
13
10
 
14
11
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
15
12
 
16
- const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
17
13
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
14
+ const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
18
15
 
19
- function isObject(value) {
20
- return value !== null && typeof value === "object";
21
- }
22
- function _defu(baseObject, defaults, namespace = ".", merger) {
23
- if (!isObject(defaults)) {
24
- return _defu(baseObject, {}, namespace, merger);
25
- }
26
- const object = Object.assign({}, defaults);
27
- for (const key in baseObject) {
28
- if (key === "__proto__" || key === "constructor") {
29
- continue;
30
- }
31
- const value = baseObject[key];
32
- if (value === null || value === void 0) {
33
- continue;
34
- }
35
- if (merger && merger(object, key, value, namespace)) {
36
- continue;
37
- }
38
- if (Array.isArray(value) && Array.isArray(object[key])) {
39
- object[key] = [...value, ...object[key]];
40
- } else if (isObject(value) && isObject(object[key])) {
41
- object[key] = _defu(
42
- value,
43
- object[key],
44
- (namespace ? `${namespace}.` : "") + key.toString(),
45
- merger
46
- );
47
- } else {
48
- object[key] = value;
49
- }
50
- }
51
- return object;
52
- }
53
- function createDefu(merger) {
54
- return (...arguments_) => (
55
- // eslint-disable-next-line unicorn/no-array-reduce
56
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
57
- );
58
- }
59
- const defu = createDefu();
60
-
61
- class Context {
62
- constructor(opts) {
63
- this.options = defu(opts, config.getDefaultMangleUserConfig());
64
- this.classSet = /* @__PURE__ */ new Set();
65
- this.replaceMap = /* @__PURE__ */ new Map();
66
- this.includeMatcher = utils.createGlobMatcher(this.options.include, true);
67
- this.excludeMatcher = utils.createGlobMatcher(this.options.exclude, false);
68
- this.classGenerator = new shared.ClassGenerator(this.options.classGenerator);
69
- }
70
- mergeOptions(opts) {
71
- this.options = defu(this.options, opts);
72
- this.includeMatcher = utils.createGlobMatcher(this.options.include, true);
73
- this.excludeMatcher = utils.createGlobMatcher(this.options.exclude, false);
74
- this.classGenerator = new shared.ClassGenerator(this.options.classGenerator);
75
- }
76
- isInclude(file) {
77
- return this.includeMatcher(file) && !this.excludeMatcher(file);
78
- }
79
- currentMangleClassFilter(className) {
80
- return (this.options.mangleClassFilter ?? shared.defaultMangleClassFilter)(className);
81
- }
82
- getClassSet() {
83
- return this.classSet;
84
- }
85
- getReplaceMap() {
86
- return this.replaceMap;
87
- }
88
- addToUsedBy(key, file) {
89
- const hit = this.classGenerator.newClassMap[key];
90
- if (hit) {
91
- hit.usedBy.add(file);
92
- }
93
- }
94
- async initConfig() {
95
- const { config: config$1 } = await config.getConfig();
96
- const mangleConfig = config$1?.mangle;
97
- this.mergeOptions(mangleConfig);
98
- const jsonPath = this.options.classListPath ?? path.resolve(process.cwd(), config$1?.patch?.output?.filename);
99
- if (jsonPath && fs__default.existsSync(jsonPath)) {
100
- const rawClassList = fs__default.readFileSync(jsonPath, "utf8");
101
- const list = JSON.parse(rawClassList);
102
- const classList = fastSort.sort(list).desc((c) => c.length);
103
- for (const className of classList) {
104
- if (this.currentMangleClassFilter(className)) {
105
- this.classSet.add(className);
106
- }
107
- }
108
- }
109
- for (const cls of this.classSet) {
110
- this.classGenerator.generateClassName(cls);
111
- }
112
- for (const x of Object.entries(this.classGenerator.newClassMap)) {
113
- this.replaceMap.set(x[0], x[1].name);
114
- }
115
- return config$1;
116
- }
117
- }
118
-
119
- const unplugin = unplugin$1.createUnplugin((options = {}) => {
120
- const ctx = new Context(options);
121
- if (ctx.options.disabled) {
122
- return {
123
- name: utils.pluginName
124
- };
125
- }
16
+ const unplugin = unplugin$1.createUnplugin((options) => {
17
+ const ctx = new core.Context();
126
18
  return {
127
19
  name: utils.pluginName,
128
20
  enforce: "pre",
129
21
  async buildStart() {
130
- await ctx.initConfig();
22
+ await ctx.initConfig({
23
+ mangleOptions: options
24
+ });
131
25
  },
132
26
  transformInclude(id) {
133
27
  return ctx.isInclude(id);
134
28
  },
135
29
  transform(code, id) {
30
+ const s = new MagicString__default(code);
136
31
  const replaceMap = ctx.getReplaceMap();
137
- if (/\.[jt]sx?$/.test(id)) {
138
- const str = core.preProcessJs({
139
- code,
140
- replaceMap,
141
- addToUsedBy: ctx.addToUsedBy.bind(ctx),
142
- id
143
- });
144
- return str;
145
- } else {
146
- for (const [key, value] of replaceMap) {
147
- code = code.replaceAll(key, value);
148
- }
149
- }
150
- return code;
32
+ return /\.[jt]sx?$/.test(id) ? core.preProcessJs({
33
+ code: s,
34
+ replaceMap,
35
+ ctx,
36
+ id
37
+ }) : core.preProcessRawCode({
38
+ code,
39
+ ctx,
40
+ replaceMap,
41
+ id
42
+ });
151
43
  },
152
44
  vite: {
153
45
  generateBundle: {
@@ -160,7 +52,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
160
52
  const { css } = await core.cssHandler(cssSource.source.toString(), {
161
53
  file,
162
54
  replaceMap,
163
- classGenerator: ctx.classGenerator
55
+ ctx
164
56
  });
165
57
  cssSource.source = css;
166
58
  }
@@ -185,7 +77,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
185
77
  const [file, chunk] = groupedEntries.js[i];
186
78
  const code = core.jsHandler(chunk.source().toString(), {
187
79
  replaceMap,
188
- classGenerator: ctx.classGenerator
80
+ ctx
189
81
  }).code;
190
82
  if (code) {
191
83
  const source = new ConcatSource(code);
@@ -199,7 +91,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
199
91
  const { css } = await core.cssHandler(cssSource.source().toString(), {
200
92
  replaceMap,
201
93
  file,
202
- classGenerator: ctx.classGenerator
94
+ ctx
203
95
  });
204
96
  const source = new ConcatSource(css);
205
97
  compilation.updateAsset(file, source);
@@ -209,7 +101,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
209
101
  for (let i = 0; i < groupedEntries.html.length; i++) {
210
102
  const [file, asset] = groupedEntries.html[i];
211
103
  const html = core.htmlHandler(asset.source().toString(), {
212
- classGenerator: ctx.classGenerator,
104
+ ctx,
213
105
  replaceMap
214
106
  });
215
107
  const source = new ConcatSource(html);
@@ -226,21 +118,18 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
226
118
  const entries = Object.entries(ctx.classGenerator.newClassMap);
227
119
  if (entries.length > 0 && opts) {
228
120
  await utils.ensureDir(path.dirname(opts.filename));
229
- await fs__default$1.writeFile(
230
- opts.filename,
231
- JSON.stringify(
232
- entries.map((x) => {
233
- return {
234
- origin: x[0],
235
- replacement: x[1].name,
236
- usedBy: [...x[1].usedBy]
237
- };
238
- }),
239
- null,
240
- 2
241
- ),
242
- "utf8"
121
+ const output = JSON.stringify(
122
+ entries.map((x) => {
123
+ return {
124
+ origin: x[0],
125
+ replacement: x[1].name,
126
+ usedBy: [...x[1].usedBy]
127
+ };
128
+ }),
129
+ null,
130
+ opts.loose ? 2 : 0
243
131
  );
132
+ await fs__default.writeFile(opts.filename, output, "utf8");
244
133
  console.log(`\u2728 ${opts.filename} generated!`);
245
134
  }
246
135
  }
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig, boolean>;
5
+
6
+ export { unplugin as default };
@@ -0,0 +1,6 @@
1
+ import * as _unplugin from 'unplugin';
2
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
3
+
4
+ declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig, boolean>;
5
+
6
+ export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,146 +1,38 @@
1
- import { resolve, dirname } from 'node:path';
2
- import fs$1 from 'node:fs/promises';
1
+ import { dirname } from 'node:path';
2
+ import fs from 'node:fs/promises';
3
3
  import { createUnplugin } from 'unplugin';
4
- import { preProcessJs, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
5
- import fs from 'node:fs';
6
- import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
7
- import { getDefaultMangleUserConfig, getConfig } from '@tailwindcss-mangle/config';
8
- import { sort } from 'fast-sort';
9
- import { c as createGlobMatcher, p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
- import 'micromatch';
4
+ import { Context, preProcessJs, preProcessRawCode, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
5
+ import MagicString from 'magic-string';
6
+ import { p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
7
+ import '@tailwindcss-mangle/shared';
11
8
 
12
- function isObject(value) {
13
- return value !== null && typeof value === "object";
14
- }
15
- function _defu(baseObject, defaults, namespace = ".", merger) {
16
- if (!isObject(defaults)) {
17
- return _defu(baseObject, {}, namespace, merger);
18
- }
19
- const object = Object.assign({}, defaults);
20
- for (const key in baseObject) {
21
- if (key === "__proto__" || key === "constructor") {
22
- continue;
23
- }
24
- const value = baseObject[key];
25
- if (value === null || value === void 0) {
26
- continue;
27
- }
28
- if (merger && merger(object, key, value, namespace)) {
29
- continue;
30
- }
31
- if (Array.isArray(value) && Array.isArray(object[key])) {
32
- object[key] = [...value, ...object[key]];
33
- } else if (isObject(value) && isObject(object[key])) {
34
- object[key] = _defu(
35
- value,
36
- object[key],
37
- (namespace ? `${namespace}.` : "") + key.toString(),
38
- merger
39
- );
40
- } else {
41
- object[key] = value;
42
- }
43
- }
44
- return object;
45
- }
46
- function createDefu(merger) {
47
- return (...arguments_) => (
48
- // eslint-disable-next-line unicorn/no-array-reduce
49
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
50
- );
51
- }
52
- const defu = createDefu();
53
-
54
- class Context {
55
- constructor(opts) {
56
- this.options = defu(opts, getDefaultMangleUserConfig());
57
- this.classSet = /* @__PURE__ */ new Set();
58
- this.replaceMap = /* @__PURE__ */ new Map();
59
- this.includeMatcher = createGlobMatcher(this.options.include, true);
60
- this.excludeMatcher = createGlobMatcher(this.options.exclude, false);
61
- this.classGenerator = new ClassGenerator(this.options.classGenerator);
62
- }
63
- mergeOptions(opts) {
64
- this.options = defu(this.options, opts);
65
- this.includeMatcher = createGlobMatcher(this.options.include, true);
66
- this.excludeMatcher = createGlobMatcher(this.options.exclude, false);
67
- this.classGenerator = new ClassGenerator(this.options.classGenerator);
68
- }
69
- isInclude(file) {
70
- return this.includeMatcher(file) && !this.excludeMatcher(file);
71
- }
72
- currentMangleClassFilter(className) {
73
- return (this.options.mangleClassFilter ?? defaultMangleClassFilter)(className);
74
- }
75
- getClassSet() {
76
- return this.classSet;
77
- }
78
- getReplaceMap() {
79
- return this.replaceMap;
80
- }
81
- addToUsedBy(key, file) {
82
- const hit = this.classGenerator.newClassMap[key];
83
- if (hit) {
84
- hit.usedBy.add(file);
85
- }
86
- }
87
- async initConfig() {
88
- const { config } = await getConfig();
89
- const mangleConfig = config?.mangle;
90
- this.mergeOptions(mangleConfig);
91
- const jsonPath = this.options.classListPath ?? resolve(process.cwd(), config?.patch?.output?.filename);
92
- if (jsonPath && fs.existsSync(jsonPath)) {
93
- const rawClassList = fs.readFileSync(jsonPath, "utf8");
94
- const list = JSON.parse(rawClassList);
95
- const classList = sort(list).desc((c) => c.length);
96
- for (const className of classList) {
97
- if (this.currentMangleClassFilter(className)) {
98
- this.classSet.add(className);
99
- }
100
- }
101
- }
102
- for (const cls of this.classSet) {
103
- this.classGenerator.generateClassName(cls);
104
- }
105
- for (const x of Object.entries(this.classGenerator.newClassMap)) {
106
- this.replaceMap.set(x[0], x[1].name);
107
- }
108
- return config;
109
- }
110
- }
111
-
112
- const unplugin = createUnplugin((options = {}) => {
113
- const ctx = new Context(options);
114
- if (ctx.options.disabled) {
115
- return {
116
- name: pluginName
117
- };
118
- }
9
+ const unplugin = createUnplugin((options) => {
10
+ const ctx = new Context();
119
11
  return {
120
12
  name: pluginName,
121
13
  enforce: "pre",
122
14
  async buildStart() {
123
- await ctx.initConfig();
15
+ await ctx.initConfig({
16
+ mangleOptions: options
17
+ });
124
18
  },
125
19
  transformInclude(id) {
126
20
  return ctx.isInclude(id);
127
21
  },
128
22
  transform(code, id) {
23
+ const s = new MagicString(code);
129
24
  const replaceMap = ctx.getReplaceMap();
130
- if (/\.[jt]sx?$/.test(id)) {
131
- const str = preProcessJs({
132
- code,
133
- replaceMap,
134
- addToUsedBy: ctx.addToUsedBy.bind(ctx),
135
- id
136
- });
137
- return str;
138
- } else {
139
- for (const [key, value] of replaceMap) {
140
- code = code.replaceAll(key, value);
141
- }
142
- }
143
- return code;
25
+ return /\.[jt]sx?$/.test(id) ? preProcessJs({
26
+ code: s,
27
+ replaceMap,
28
+ ctx,
29
+ id
30
+ }) : preProcessRawCode({
31
+ code,
32
+ ctx,
33
+ replaceMap,
34
+ id
35
+ });
144
36
  },
145
37
  vite: {
146
38
  generateBundle: {
@@ -153,7 +45,7 @@ const unplugin = createUnplugin((options = {}) => {
153
45
  const { css } = await cssHandler(cssSource.source.toString(), {
154
46
  file,
155
47
  replaceMap,
156
- classGenerator: ctx.classGenerator
48
+ ctx
157
49
  });
158
50
  cssSource.source = css;
159
51
  }
@@ -178,7 +70,7 @@ const unplugin = createUnplugin((options = {}) => {
178
70
  const [file, chunk] = groupedEntries.js[i];
179
71
  const code = jsHandler(chunk.source().toString(), {
180
72
  replaceMap,
181
- classGenerator: ctx.classGenerator
73
+ ctx
182
74
  }).code;
183
75
  if (code) {
184
76
  const source = new ConcatSource(code);
@@ -192,7 +84,7 @@ const unplugin = createUnplugin((options = {}) => {
192
84
  const { css } = await cssHandler(cssSource.source().toString(), {
193
85
  replaceMap,
194
86
  file,
195
- classGenerator: ctx.classGenerator
87
+ ctx
196
88
  });
197
89
  const source = new ConcatSource(css);
198
90
  compilation.updateAsset(file, source);
@@ -202,7 +94,7 @@ const unplugin = createUnplugin((options = {}) => {
202
94
  for (let i = 0; i < groupedEntries.html.length; i++) {
203
95
  const [file, asset] = groupedEntries.html[i];
204
96
  const html = htmlHandler(asset.source().toString(), {
205
- classGenerator: ctx.classGenerator,
97
+ ctx,
206
98
  replaceMap
207
99
  });
208
100
  const source = new ConcatSource(html);
@@ -219,21 +111,18 @@ const unplugin = createUnplugin((options = {}) => {
219
111
  const entries = Object.entries(ctx.classGenerator.newClassMap);
220
112
  if (entries.length > 0 && opts) {
221
113
  await ensureDir(dirname(opts.filename));
222
- await fs$1.writeFile(
223
- opts.filename,
224
- JSON.stringify(
225
- entries.map((x) => {
226
- return {
227
- origin: x[0],
228
- replacement: x[1].name,
229
- usedBy: [...x[1].usedBy]
230
- };
231
- }),
232
- null,
233
- 2
234
- ),
235
- "utf8"
114
+ const output = JSON.stringify(
115
+ entries.map((x) => {
116
+ return {
117
+ origin: x[0],
118
+ replacement: x[1].name,
119
+ usedBy: [...x[1].usedBy]
120
+ };
121
+ }),
122
+ null,
123
+ opts.loose ? 2 : 0
236
124
  );
125
+ await fs.writeFile(opts.filename, output, "utf8");
237
126
  console.log(`\u2728 ${opts.filename} generated!`);
238
127
  }
239
128
  }
package/dist/nuxt.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
5
  require('node:fs/promises');
10
- require('micromatch');
11
6
  require('unplugin');
12
7
  require('@tailwindcss-mangle/core');
13
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+ require('magic-string');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
14
11
 
15
12
  function nuxt(options = {}, nuxt) {
16
13
  nuxt.hook("webpack:config", (config) => {
@@ -0,0 +1,5 @@
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 };
@@ -0,0 +1,5 @@
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 CHANGED
@@ -1,14 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
3
  import 'node:fs/promises';
8
- import 'micromatch';
9
4
  import 'unplugin';
10
5
  import '@tailwindcss-mangle/core';
11
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
6
+ import 'magic-string';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
12
9
 
13
10
  function nuxt(options = {}, nuxt) {
14
11
  nuxt.hook("webpack:config", (config) => {
package/dist/rollup.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
5
  require('node:fs/promises');
10
- require('micromatch');
11
6
  require('unplugin');
12
7
  require('@tailwindcss-mangle/core');
13
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+ require('magic-string');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
14
11
 
15
12
  const rollup = index.rollup;
16
13
 
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as rollup from 'rollup';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
+
6
+ export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
2
  import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
3
 
4
- declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin | rollup.Plugin[];
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin<any> | rollup.Plugin<any>[];
5
5
 
6
6
  export { _default as default };
package/dist/rollup.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
3
  import 'node:fs/promises';
8
- import 'micromatch';
9
4
  import 'unplugin';
10
5
  import '@tailwindcss-mangle/core';
11
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
6
+ import 'magic-string';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
12
9
 
13
10
  const rollup = unplugin.rollup;
14
11
 
@@ -2,18 +2,21 @@
2
2
 
3
3
  const fs = require('node:fs/promises');
4
4
  const path = require('node:path');
5
- const micromatch = require('micromatch');
6
5
  const shared = require('@tailwindcss-mangle/shared');
7
6
 
8
7
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
8
 
10
9
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
11
10
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
- const micromatch__default = /*#__PURE__*/_interopDefaultCompat(micromatch);
13
11
 
14
12
  const pluginName = "unplugin-tailwindcss-mangle";
15
13
 
16
- const { isMatch } = micromatch__default;
14
+ function escapeStringRegexp(str) {
15
+ if (typeof str !== "string") {
16
+ throw new TypeError("Expected a string");
17
+ }
18
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
19
+ }
17
20
  function getGroupedEntries(entries, options = {
18
21
  cssMatcher(file) {
19
22
  return /\.css$/.test(file);
@@ -51,16 +54,6 @@ function getGroupedEntries(entries, options = {
51
54
  }
52
55
  return groupedEntries;
53
56
  }
54
- function createGlobMatcher(pattern, fallbackValue = false) {
55
- if (pattern === void 0) {
56
- return function() {
57
- return fallbackValue;
58
- };
59
- }
60
- return function(file) {
61
- return isMatch(file, pattern);
62
- };
63
- }
64
57
  function getCacheDir(basedir = process.cwd()) {
65
58
  return path__default.resolve(basedir, "node_modules/.cache", pluginName);
66
59
  }
@@ -74,8 +67,8 @@ async function ensureDir(p) {
74
67
  }
75
68
  }
76
69
 
77
- exports.createGlobMatcher = createGlobMatcher;
78
70
  exports.ensureDir = ensureDir;
71
+ exports.escapeStringRegexp = escapeStringRegexp;
79
72
  exports.getCacheDir = getCacheDir;
80
73
  exports.getGroupedEntries = getGroupedEntries;
81
74
  exports.pluginName = pluginName;
@@ -1,11 +1,15 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import micromatch from 'micromatch';
4
3
  import { groupBy } from '@tailwindcss-mangle/shared';
5
4
 
6
5
  const pluginName = "unplugin-tailwindcss-mangle";
7
6
 
8
- const { isMatch } = micromatch;
7
+ function escapeStringRegexp(str) {
8
+ if (typeof str !== "string") {
9
+ throw new TypeError("Expected a string");
10
+ }
11
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
12
+ }
9
13
  function getGroupedEntries(entries, options = {
10
14
  cssMatcher(file) {
11
15
  return /\.css$/.test(file);
@@ -43,16 +47,6 @@ function getGroupedEntries(entries, options = {
43
47
  }
44
48
  return groupedEntries;
45
49
  }
46
- function createGlobMatcher(pattern, fallbackValue = false) {
47
- if (pattern === void 0) {
48
- return function() {
49
- return fallbackValue;
50
- };
51
- }
52
- return function(file) {
53
- return isMatch(file, pattern);
54
- };
55
- }
56
50
  function getCacheDir(basedir = process.cwd()) {
57
51
  return path.resolve(basedir, "node_modules/.cache", pluginName);
58
52
  }
@@ -66,4 +60,4 @@ async function ensureDir(p) {
66
60
  }
67
61
  }
68
62
 
69
- export { getCacheDir as a, createGlobMatcher as c, ensureDir as e, getGroupedEntries as g, pluginName as p };
63
+ export { escapeStringRegexp as a, getCacheDir as b, ensureDir as e, getGroupedEntries as g, pluginName as p };
package/dist/utils.cjs CHANGED
@@ -2,16 +2,15 @@
2
2
 
3
3
  require('node:fs/promises');
4
4
  require('node:path');
5
- require('micromatch');
6
5
  const shared = require('@tailwindcss-mangle/shared');
7
- const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
6
+ const utils = require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
8
7
 
9
8
 
10
9
 
11
10
  exports.defaultMangleClassFilter = shared.defaultMangleClassFilter;
12
11
  exports.isMap = shared.isMap;
13
12
  exports.isRegexp = shared.isRegexp;
14
- exports.createGlobMatcher = utils.createGlobMatcher;
15
13
  exports.ensureDir = utils.ensureDir;
14
+ exports.escapeStringRegexp = utils.escapeStringRegexp;
16
15
  exports.getCacheDir = utils.getCacheDir;
17
16
  exports.getGroupedEntries = utils.getGroupedEntries;
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function escapeStringRegexp(str: string): string;
4
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
5
+ cssMatcher(file: string): boolean;
6
+ htmlMatcher(file: string): boolean;
7
+ jsMatcher(file: string): boolean;
8
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
2
 
3
+ declare function escapeStringRegexp(str: string): string;
3
4
  declare function getGroupedEntries<T>(entries: [string, T][], options?: {
4
5
  cssMatcher(file: string): boolean;
5
6
  htmlMatcher(file: string): boolean;
6
7
  jsMatcher(file: string): boolean;
7
8
  }): Record<"css" | "html" | "js" | "other", [string, T][]>;
8
- declare function createGlobMatcher(pattern: string | string[] | undefined, fallbackValue?: boolean): (file: string) => boolean;
9
9
  declare function getCacheDir(basedir?: string): string;
10
10
  declare function ensureDir(p: string): Promise<void>;
11
11
 
12
- export { createGlobMatcher, ensureDir, getCacheDir, getGroupedEntries };
12
+ export { ensureDir, escapeStringRegexp, getCacheDir, getGroupedEntries };
package/dist/utils.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import 'node:fs/promises';
2
2
  import 'node:path';
3
- import 'micromatch';
4
3
  export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
5
- export { c as createGlobMatcher, e as ensureDir, a as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
4
+ export { e as ensureDir, a as escapeStringRegexp, b as getCacheDir, g as getGroupedEntries } from './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
package/dist/vite.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
5
  require('node:fs/promises');
10
- require('micromatch');
11
6
  require('unplugin');
12
7
  require('@tailwindcss-mangle/core');
13
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+ require('magic-string');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
14
11
 
15
12
  const vite = index.vite;
16
13
 
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => vite.Plugin | vite.Plugin[];
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as vite from 'vite';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => vite.Plugin | vite.Plugin[];
5
+
6
+ export { _default as default };
package/dist/vite.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
3
  import 'node:fs/promises';
8
- import 'micromatch';
9
4
  import 'unplugin';
10
5
  import '@tailwindcss-mangle/core';
11
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
6
+ import 'magic-string';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
12
9
 
13
10
  const vite = unplugin.vite;
14
11
 
package/dist/webpack.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- require('node:fs');
5
4
  require('node:path');
6
- require('@tailwindcss-mangle/shared');
7
- require('@tailwindcss-mangle/config');
8
- require('fast-sort');
9
5
  require('node:fs/promises');
10
- require('micromatch');
11
6
  require('unplugin');
12
7
  require('@tailwindcss-mangle/core');
13
- require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+ require('magic-string');
9
+ require('./shared/unplugin-tailwindcss-mangle.43bd55b2.cjs');
10
+ require('@tailwindcss-mangle/shared');
14
11
 
15
12
  const webpack = index.webpack;
16
13
 
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => webpack.WebpackPluginInstance;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as webpack from 'webpack';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
3
+
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => webpack.WebpackPluginInstance;
5
+
6
+ export { _default as default };
package/dist/webpack.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import unplugin from './index.mjs';
2
- import 'node:fs';
3
2
  import 'node:path';
4
- import '@tailwindcss-mangle/shared';
5
- import '@tailwindcss-mangle/config';
6
- import 'fast-sort';
7
3
  import 'node:fs/promises';
8
- import 'micromatch';
9
4
  import 'unplugin';
10
5
  import '@tailwindcss-mangle/core';
11
- import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
6
+ import 'magic-string';
7
+ import './shared/unplugin-tailwindcss-mangle.9275c584.mjs';
8
+ import '@tailwindcss-mangle/shared';
12
9
 
13
10
  const webpack = unplugin.webpack;
14
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "2.0.6",
3
+ "version": "2.2.0",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -65,12 +65,11 @@
65
65
  "author": "SonOfMagic <qq1324318532@gmail.com>",
66
66
  "license": "MIT",
67
67
  "dependencies": {
68
- "fast-sort": "^3.4.0",
69
- "micromatch": "^4.0.5",
68
+ "magic-string": "^0.30.3",
70
69
  "unplugin": "^1.4.0",
71
- "@tailwindcss-mangle/config": "^2.0.4",
72
- "@tailwindcss-mangle/core": "^2.0.6",
73
- "@tailwindcss-mangle/shared": "^2.0.4"
70
+ "@tailwindcss-mangle/config": "^2.2.0",
71
+ "@tailwindcss-mangle/core": "^2.2.0",
72
+ "@tailwindcss-mangle/shared": "^2.2.0"
74
73
  },
75
74
  "publishConfig": {
76
75
  "access": "public",
@@ -78,17 +77,18 @@
78
77
  },
79
78
  "devDependencies": {
80
79
  "@types/babel__helper-plugin-utils": "^7.10.0",
81
- "@types/micromatch": "^4.0.2",
80
+ "astro": "^2.10.12",
82
81
  "css-loader": "^6.8.1",
83
82
  "html-webpack-plugin": "^5.5.3",
84
83
  "mini-css-extract-plugin": "^2.7.6",
85
- "postcss": "^8.4.27",
84
+ "normalize-newline": "^4.1.0",
85
+ "postcss": "^8.4.29",
86
86
  "postcss-loader": "^7.3.3",
87
87
  "tailwindcss": "^3.3.3",
88
88
  "vite": "^4.4.9",
89
89
  "webpack": "^5.88.2",
90
90
  "webpack-build-utils": "^0.0.4",
91
- "tailwindcss-patch": "^2.0.4"
91
+ "tailwindcss-patch": "^2.2.0"
92
92
  },
93
93
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
94
94
  "repository": {
@@ -96,6 +96,7 @@
96
96
  "url": "git+https://github.com/sonofmagic/tailwindcss-mangle.git"
97
97
  },
98
98
  "scripts": {
99
+ "dev": "unbuild --sourcemap",
99
100
  "build": "unbuild",
100
101
  "test": "vitest run --coverage.enabled",
101
102
  "test:dev": "vitest"