unplugin-tailwindcss-mangle 2.0.2 → 2.0.6

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
@@ -16,6 +16,7 @@ It is recommended to read the documentation of [tailwindcss-patch](https://githu
16
16
  - [5. Register this plugin](#5-register-this-plugin)
17
17
  - [vite](#vite)
18
18
  - [webpack](#webpack)
19
+ - [Nuxt 3](#nuxt-3)
19
20
  - [Options](#options)
20
21
  - [Notice](#notice)
21
22
  - [Migration form v1 to v2](#migration-form-v1-to-v2)
@@ -111,6 +112,29 @@ module.exports = defineConfig({
111
112
 
112
113
  ```
113
114
 
115
+ #### Nuxt 3
116
+
117
+ ```ts
118
+ import nuxtPlugin from 'unplugin-tailwindcss-mangle/nuxt'
119
+ export default defineNuxtConfig({
120
+ //...
121
+ // https://github.com/nuxt/nuxt/issues/20428
122
+ // you must set this option to false to enable vite extract css
123
+ experimental: {
124
+ inlineSSRStyles: false
125
+ },
126
+ modules: [
127
+ [
128
+ nuxtPlugin,
129
+ {
130
+ // options
131
+ }
132
+ ]
133
+ ]
134
+ })
135
+
136
+ ```
137
+
114
138
  ## Options
115
139
 
116
140
  [types.ts]('./src/types.ts')
package/dist/esbuild.cjs CHANGED
@@ -6,9 +6,11 @@ require('node:path');
6
6
  require('@tailwindcss-mangle/shared');
7
7
  require('@tailwindcss-mangle/config');
8
8
  require('fast-sort');
9
- require('@tailwindcss-mangle/core');
9
+ require('node:fs/promises');
10
10
  require('micromatch');
11
11
  require('unplugin');
12
+ require('@tailwindcss-mangle/core');
13
+ require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
14
 
13
15
  const esbuild = index.esbuild;
14
16
 
package/dist/esbuild.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as esbuild from 'esbuild';
2
- import { O as Options } from './types-3f814672.js';
3
- import '@tailwindcss-mangle/shared';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
4
3
 
5
- declare const _default: (options?: Options | undefined) => esbuild.Plugin;
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => esbuild.Plugin;
6
5
 
7
6
  export { _default as default };
package/dist/esbuild.mjs CHANGED
@@ -4,9 +4,11 @@ import 'node:path';
4
4
  import '@tailwindcss-mangle/shared';
5
5
  import '@tailwindcss-mangle/config';
6
6
  import 'fast-sort';
7
- import '@tailwindcss-mangle/core';
7
+ import 'node:fs/promises';
8
8
  import 'micromatch';
9
9
  import 'unplugin';
10
+ import '@tailwindcss-mangle/core';
11
+ import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
12
 
11
13
  const esbuild = unplugin.esbuild;
12
14
 
package/dist/index.cjs CHANGED
@@ -1,19 +1,20 @@
1
1
  'use strict';
2
2
 
3
+ const path = require('node:path');
4
+ const fs$1 = require('node:fs/promises');
3
5
  const unplugin$1 = require('unplugin');
6
+ const core = require('@tailwindcss-mangle/core');
4
7
  const fs = require('node:fs');
5
- const path = require('node:path');
6
8
  const shared = require('@tailwindcss-mangle/shared');
7
9
  const config = require('@tailwindcss-mangle/config');
8
10
  const fastSort = require('fast-sort');
9
- const core = require('@tailwindcss-mangle/core');
10
- const micromatch = require('micromatch');
11
+ const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
+ require('micromatch');
11
13
 
12
14
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
13
15
 
16
+ const fs__default$1 = /*#__PURE__*/_interopDefaultCompat(fs$1);
14
17
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
15
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
16
- const micromatch__default = /*#__PURE__*/_interopDefaultCompat(micromatch);
17
18
 
18
19
  function isObject(value) {
19
20
  return value !== null && typeof value === "object";
@@ -57,189 +58,87 @@ function createDefu(merger) {
57
58
  }
58
59
  const defu = createDefu();
59
60
 
60
- const pluginName = "unplugin-tailwindcss-mangle";
61
-
62
- const { isMatch } = micromatch__default;
63
- function getGroupedEntries(entries, options = {
64
- cssMatcher(file) {
65
- return /\.css$/.test(file);
66
- },
67
- htmlMatcher(file) {
68
- return /\.html?$/.test(file);
69
- },
70
- jsMatcher(file) {
71
- return /\.[cm]?js$/.test(file);
72
- }
73
- }) {
74
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
75
- const groupedEntries = shared.groupBy(entries, ([file]) => {
76
- if (cssMatcher(file)) {
77
- return "css";
78
- } else if (htmlMatcher(file)) {
79
- return "html";
80
- } else if (jsMatcher(file)) {
81
- return "js";
82
- } else {
83
- return "other";
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);
84
92
  }
85
- });
86
- if (!groupedEntries.css) {
87
- groupedEntries.css = [];
88
- }
89
- if (!groupedEntries.html) {
90
- groupedEntries.html = [];
91
- }
92
- if (!groupedEntries.js) {
93
- groupedEntries.js = [];
94
- }
95
- if (!groupedEntries.other) {
96
- groupedEntries.other = [];
97
- }
98
- return groupedEntries;
99
- }
100
- function createGlobMatcher(pattern, fallbackValue = false) {
101
- if (pattern === void 0) {
102
- return function() {
103
- return fallbackValue;
104
- };
105
- }
106
- return function(file) {
107
- return isMatch(file, pattern);
108
- };
109
- }
110
- function getCacheDir(basedir = process.cwd()) {
111
- return path__default.resolve(basedir, "node_modules/.cache", pluginName);
112
- }
113
- function mkCacheDirectory(cwd = process.cwd()) {
114
- const cacheDirectory = getCacheDir(cwd);
115
- const exists = fs__default.existsSync(cacheDirectory);
116
- if (!exists) {
117
- fs__default.mkdirSync(cacheDirectory, {
118
- recursive: true
119
- });
120
93
  }
121
- return cacheDirectory;
122
- }
123
- function cacheDump(filename, data, basedir) {
124
- try {
125
- const dir = mkCacheDirectory(basedir);
126
- fs__default.writeFileSync(path__default.resolve(dir, filename), JSON.stringify([...data], void 0, 2), "utf8");
127
- } catch (error) {
128
- console.log(error);
129
- }
130
- }
131
-
132
- function getOptions(opts = {}) {
133
- const {
134
- include,
135
- exclude,
136
- disabled,
137
- mangleClassFilter,
138
- classMapOutput,
139
- classGenerator: classGeneratorOptions,
140
- classListPath: _classListPath
141
- } = defu(opts, {
142
- include: ["**/*.{js,jsx,ts,tsx,svelte,vue}"],
143
- exclude: ["**/*.{css,scss,less,sass,postcss,html,htm}"],
144
- disabled: process.env.NODE_ENV === "development"
145
- });
146
- const includeMatcher = createGlobMatcher(include, true);
147
- const excludeMatcher = createGlobMatcher(exclude, false);
148
- const currentMangleClassFilter = mangleClassFilter ?? shared.defaultMangleClassFilter;
149
- function isInclude(file) {
150
- return includeMatcher(file) && !excludeMatcher(file);
151
- }
152
- const classSet = /* @__PURE__ */ new Set();
153
- const replaceMap = /* @__PURE__ */ new Map();
154
- let userConfig = config.getDefaultUserConfig();
155
- const classMapOutputOptions = {
156
- filename: "classMap.json"
157
- };
158
- if (typeof classMapOutput === "object") {
159
- Object.assign(classMapOutputOptions, classMapOutput);
160
- }
161
- const classGenerator = new shared.ClassGenerator(classGeneratorOptions);
162
- function getCachedClassSet() {
163
- return classSet;
164
- }
165
- function getReplaceMap() {
166
- return replaceMap;
167
- }
168
- async function initConfig() {
94
+ async initConfig() {
169
95
  const { config: config$1 } = await config.getConfig();
170
- userConfig = config$1;
171
- let classListPath = "";
172
- if (userConfig) {
173
- classListPath = path.resolve(process.cwd(), userConfig.patch?.output?.filename);
174
- }
175
- if (_classListPath) {
176
- classListPath = _classListPath;
177
- }
178
- if (classListPath && fs__default.existsSync(classListPath)) {
179
- const rawClassList = fs__default.readFileSync(classListPath, "utf8");
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");
180
101
  const list = JSON.parse(rawClassList);
181
102
  const classList = fastSort.sort(list).desc((c) => c.length);
182
103
  for (const className of classList) {
183
- if (currentMangleClassFilter(className)) {
184
- classSet.add(className);
104
+ if (this.currentMangleClassFilter(className)) {
105
+ this.classSet.add(className);
185
106
  }
186
107
  }
187
108
  }
188
- for (const cls of classSet) {
189
- classGenerator.generateClassName(cls);
109
+ for (const cls of this.classSet) {
110
+ this.classGenerator.generateClassName(cls);
190
111
  }
191
- for (const x of Object.entries(classGenerator.newClassMap)) {
192
- replaceMap.set(x[0], x[1].name);
112
+ for (const x of Object.entries(this.classGenerator.newClassMap)) {
113
+ this.replaceMap.set(x[0], x[1].name);
193
114
  }
194
115
  return config$1;
195
116
  }
196
- function addToUsedBy(key, file) {
197
- const hit = classGenerator.newClassMap[key];
198
- if (hit) {
199
- hit.usedBy.add(file);
200
- }
201
- }
202
- return {
203
- getCachedClassSet,
204
- classGenerator,
205
- includeMatcher,
206
- excludeMatcher,
207
- isInclude,
208
- classMapOutputOptions,
209
- initConfig,
210
- getReplaceMap,
211
- addToUsedBy,
212
- disabled,
213
- htmlHandler: core.htmlHandler,
214
- cssHandler: core.cssHandler,
215
- jsHandler: core.jsHandler,
216
- preProcessJs: core.preProcessJs
217
- };
218
117
  }
219
118
 
220
119
  const unplugin = unplugin$1.createUnplugin((options = {}) => {
221
- const { isInclude, initConfig, getReplaceMap, classGenerator, addToUsedBy, classMapOutputOptions, disabled, htmlHandler, cssHandler, jsHandler, preProcessJs } = getOptions(options);
222
- if (disabled) {
120
+ const ctx = new Context(options);
121
+ if (ctx.options.disabled) {
223
122
  return {
224
- name: pluginName
123
+ name: utils.pluginName
225
124
  };
226
125
  }
227
126
  return {
228
- name: pluginName,
127
+ name: utils.pluginName,
229
128
  enforce: "pre",
230
129
  async buildStart() {
231
- await initConfig();
130
+ await ctx.initConfig();
232
131
  },
233
132
  transformInclude(id) {
234
- return isInclude(id);
133
+ return ctx.isInclude(id);
235
134
  },
236
135
  transform(code, id) {
237
- const replaceMap = getReplaceMap();
238
- if (id.endsWith(".js") || id.endsWith(".ts") || id.endsWith(".tsx") || id.endsWith(".jsx")) {
239
- const str = preProcessJs({
136
+ const replaceMap = ctx.getReplaceMap();
137
+ if (/\.[jt]sx?$/.test(id)) {
138
+ const str = core.preProcessJs({
240
139
  code,
241
140
  replaceMap,
242
- addToUsedBy,
141
+ addToUsedBy: ctx.addToUsedBy.bind(ctx),
243
142
  id
244
143
  });
245
144
  return str;
@@ -253,15 +152,15 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
253
152
  vite: {
254
153
  generateBundle: {
255
154
  async handler(options2, bundle) {
256
- const replaceMap = getReplaceMap();
257
- const groupedEntries = getGroupedEntries(Object.entries(bundle));
155
+ const replaceMap = ctx.getReplaceMap();
156
+ const groupedEntries = utils.getGroupedEntries(Object.entries(bundle));
258
157
  if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
259
158
  for (let i = 0; i < groupedEntries.css.length; i++) {
260
159
  const [file, cssSource] = groupedEntries.css[i];
261
- const { css } = await cssHandler(cssSource.source.toString(), {
160
+ const { css } = await core.cssHandler(cssSource.source.toString(), {
262
161
  file,
263
162
  replaceMap,
264
- classGenerator
163
+ classGenerator: ctx.classGenerator
265
164
  });
266
165
  cssSource.source = css;
267
166
  }
@@ -272,21 +171,21 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
272
171
  webpack(compiler) {
273
172
  const { Compilation, sources } = compiler.webpack;
274
173
  const { ConcatSource } = sources;
275
- compiler.hooks.compilation.tap(pluginName, (compilation) => {
174
+ compiler.hooks.compilation.tap(utils.pluginName, (compilation) => {
276
175
  compilation.hooks.processAssets.tapPromise(
277
176
  {
278
- name: pluginName,
177
+ name: utils.pluginName,
279
178
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
280
179
  },
281
180
  async (assets) => {
282
- const replaceMap = getReplaceMap();
283
- const groupedEntries = getGroupedEntries(Object.entries(assets));
181
+ const replaceMap = ctx.getReplaceMap();
182
+ const groupedEntries = utils.getGroupedEntries(Object.entries(assets));
284
183
  if (groupedEntries.js.length > 0) {
285
184
  for (let i = 0; i < groupedEntries.js.length; i++) {
286
185
  const [file, chunk] = groupedEntries.js[i];
287
- const code = jsHandler(chunk.source().toString(), {
186
+ const code = core.jsHandler(chunk.source().toString(), {
288
187
  replaceMap,
289
- classGenerator
188
+ classGenerator: ctx.classGenerator
290
189
  }).code;
291
190
  if (code) {
292
191
  const source = new ConcatSource(code);
@@ -297,10 +196,10 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
297
196
  if (groupedEntries.css.length > 0) {
298
197
  for (let i = 0; i < groupedEntries.css.length; i++) {
299
198
  const [file, cssSource] = groupedEntries.css[i];
300
- const { css } = await cssHandler(cssSource.source().toString(), {
199
+ const { css } = await core.cssHandler(cssSource.source().toString(), {
301
200
  replaceMap,
302
201
  file,
303
- classGenerator
202
+ classGenerator: ctx.classGenerator
304
203
  });
305
204
  const source = new ConcatSource(css);
306
205
  compilation.updateAsset(file, source);
@@ -309,8 +208,8 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
309
208
  if (groupedEntries.html.length > 0) {
310
209
  for (let i = 0; i < groupedEntries.html.length; i++) {
311
210
  const [file, asset] = groupedEntries.html[i];
312
- const html = htmlHandler(asset.source().toString(), {
313
- classGenerator,
211
+ const html = core.htmlHandler(asset.source().toString(), {
212
+ classGenerator: ctx.classGenerator,
314
213
  replaceMap
315
214
  });
316
215
  const source = new ConcatSource(html);
@@ -321,20 +220,29 @@ const unplugin = unplugin$1.createUnplugin((options = {}) => {
321
220
  );
322
221
  });
323
222
  },
324
- writeBundle() {
325
- const entries = Object.entries(classGenerator.newClassMap);
326
- if (entries.length > 0 && classMapOutputOptions) {
327
- cacheDump(
328
- classMapOutputOptions.filename,
329
- entries.map((x) => {
330
- return {
331
- origin: x[0],
332
- replacement: x[1].name,
333
- usedBy: [...x[1].usedBy]
334
- };
335
- }),
336
- classMapOutputOptions.dir
337
- );
223
+ async writeBundle() {
224
+ if (ctx.options.classMapOutput?.enable) {
225
+ const opts = ctx.options.classMapOutput;
226
+ const entries = Object.entries(ctx.classGenerator.newClassMap);
227
+ if (entries.length > 0 && opts) {
228
+ 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"
243
+ );
244
+ console.log(`\u2728 ${opts.filename} generated!`);
245
+ }
338
246
  }
339
247
  }
340
248
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _unplugin from 'unplugin';
2
- import { O as Options } from './types-3f814672.js';
3
- import '@tailwindcss-mangle/shared';
2
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
4
3
 
5
- declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
4
+ declare const unplugin: _unplugin.UnpluginInstance<MangleUserConfig, boolean>;
6
5
 
7
6
  export { unplugin as default };
package/dist/index.mjs CHANGED
@@ -1,11 +1,13 @@
1
+ import { resolve, dirname } from 'node:path';
2
+ import fs$1 from 'node:fs/promises';
1
3
  import { createUnplugin } from 'unplugin';
4
+ import { preProcessJs, cssHandler, jsHandler, htmlHandler } from '@tailwindcss-mangle/core';
2
5
  import fs from 'node:fs';
3
- import path, { resolve } from 'node:path';
4
- import { groupBy, ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
5
- import { getDefaultUserConfig, getConfig } from '@tailwindcss-mangle/config';
6
+ import { ClassGenerator, defaultMangleClassFilter } from '@tailwindcss-mangle/shared';
7
+ import { getDefaultMangleUserConfig, getConfig } from '@tailwindcss-mangle/config';
6
8
  import { sort } from 'fast-sort';
7
- import { htmlHandler, cssHandler, jsHandler, preProcessJs } from '@tailwindcss-mangle/core';
8
- import micromatch from 'micromatch';
9
+ import { c as createGlobMatcher, p as pluginName, g as getGroupedEntries, e as ensureDir } from './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
+ import 'micromatch';
9
11
 
10
12
  function isObject(value) {
11
13
  return value !== null && typeof value === "object";
@@ -49,169 +51,67 @@ function createDefu(merger) {
49
51
  }
50
52
  const defu = createDefu();
51
53
 
52
- const pluginName = "unplugin-tailwindcss-mangle";
53
-
54
- const { isMatch } = micromatch;
55
- function getGroupedEntries(entries, options = {
56
- cssMatcher(file) {
57
- return /\.css$/.test(file);
58
- },
59
- htmlMatcher(file) {
60
- return /\.html?$/.test(file);
61
- },
62
- jsMatcher(file) {
63
- return /\.[cm]?js$/.test(file);
64
- }
65
- }) {
66
- const { cssMatcher, htmlMatcher, jsMatcher } = options;
67
- const groupedEntries = groupBy(entries, ([file]) => {
68
- if (cssMatcher(file)) {
69
- return "css";
70
- } else if (htmlMatcher(file)) {
71
- return "html";
72
- } else if (jsMatcher(file)) {
73
- return "js";
74
- } else {
75
- return "other";
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);
76
85
  }
77
- });
78
- if (!groupedEntries.css) {
79
- groupedEntries.css = [];
80
- }
81
- if (!groupedEntries.html) {
82
- groupedEntries.html = [];
83
- }
84
- if (!groupedEntries.js) {
85
- groupedEntries.js = [];
86
- }
87
- if (!groupedEntries.other) {
88
- groupedEntries.other = [];
89
- }
90
- return groupedEntries;
91
- }
92
- function createGlobMatcher(pattern, fallbackValue = false) {
93
- if (pattern === void 0) {
94
- return function() {
95
- return fallbackValue;
96
- };
97
- }
98
- return function(file) {
99
- return isMatch(file, pattern);
100
- };
101
- }
102
- function getCacheDir(basedir = process.cwd()) {
103
- return path.resolve(basedir, "node_modules/.cache", pluginName);
104
- }
105
- function mkCacheDirectory(cwd = process.cwd()) {
106
- const cacheDirectory = getCacheDir(cwd);
107
- const exists = fs.existsSync(cacheDirectory);
108
- if (!exists) {
109
- fs.mkdirSync(cacheDirectory, {
110
- recursive: true
111
- });
112
- }
113
- return cacheDirectory;
114
- }
115
- function cacheDump(filename, data, basedir) {
116
- try {
117
- const dir = mkCacheDirectory(basedir);
118
- fs.writeFileSync(path.resolve(dir, filename), JSON.stringify([...data], void 0, 2), "utf8");
119
- } catch (error) {
120
- console.log(error);
121
86
  }
122
- }
123
-
124
- function getOptions(opts = {}) {
125
- const {
126
- include,
127
- exclude,
128
- disabled,
129
- mangleClassFilter,
130
- classMapOutput,
131
- classGenerator: classGeneratorOptions,
132
- classListPath: _classListPath
133
- } = defu(opts, {
134
- include: ["**/*.{js,jsx,ts,tsx,svelte,vue}"],
135
- exclude: ["**/*.{css,scss,less,sass,postcss,html,htm}"],
136
- disabled: process.env.NODE_ENV === "development"
137
- });
138
- const includeMatcher = createGlobMatcher(include, true);
139
- const excludeMatcher = createGlobMatcher(exclude, false);
140
- const currentMangleClassFilter = mangleClassFilter ?? defaultMangleClassFilter;
141
- function isInclude(file) {
142
- return includeMatcher(file) && !excludeMatcher(file);
143
- }
144
- const classSet = /* @__PURE__ */ new Set();
145
- const replaceMap = /* @__PURE__ */ new Map();
146
- let userConfig = getDefaultUserConfig();
147
- const classMapOutputOptions = {
148
- filename: "classMap.json"
149
- };
150
- if (typeof classMapOutput === "object") {
151
- Object.assign(classMapOutputOptions, classMapOutput);
152
- }
153
- const classGenerator = new ClassGenerator(classGeneratorOptions);
154
- function getCachedClassSet() {
155
- return classSet;
156
- }
157
- function getReplaceMap() {
158
- return replaceMap;
159
- }
160
- async function initConfig() {
87
+ async initConfig() {
161
88
  const { config } = await getConfig();
162
- userConfig = config;
163
- let classListPath = "";
164
- if (userConfig) {
165
- classListPath = resolve(process.cwd(), userConfig.patch?.output?.filename);
166
- }
167
- if (_classListPath) {
168
- classListPath = _classListPath;
169
- }
170
- if (classListPath && fs.existsSync(classListPath)) {
171
- const rawClassList = fs.readFileSync(classListPath, "utf8");
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");
172
94
  const list = JSON.parse(rawClassList);
173
95
  const classList = sort(list).desc((c) => c.length);
174
96
  for (const className of classList) {
175
- if (currentMangleClassFilter(className)) {
176
- classSet.add(className);
97
+ if (this.currentMangleClassFilter(className)) {
98
+ this.classSet.add(className);
177
99
  }
178
100
  }
179
101
  }
180
- for (const cls of classSet) {
181
- classGenerator.generateClassName(cls);
102
+ for (const cls of this.classSet) {
103
+ this.classGenerator.generateClassName(cls);
182
104
  }
183
- for (const x of Object.entries(classGenerator.newClassMap)) {
184
- replaceMap.set(x[0], x[1].name);
105
+ for (const x of Object.entries(this.classGenerator.newClassMap)) {
106
+ this.replaceMap.set(x[0], x[1].name);
185
107
  }
186
108
  return config;
187
109
  }
188
- function addToUsedBy(key, file) {
189
- const hit = classGenerator.newClassMap[key];
190
- if (hit) {
191
- hit.usedBy.add(file);
192
- }
193
- }
194
- return {
195
- getCachedClassSet,
196
- classGenerator,
197
- includeMatcher,
198
- excludeMatcher,
199
- isInclude,
200
- classMapOutputOptions,
201
- initConfig,
202
- getReplaceMap,
203
- addToUsedBy,
204
- disabled,
205
- htmlHandler,
206
- cssHandler,
207
- jsHandler,
208
- preProcessJs
209
- };
210
110
  }
211
111
 
212
112
  const unplugin = createUnplugin((options = {}) => {
213
- const { isInclude, initConfig, getReplaceMap, classGenerator, addToUsedBy, classMapOutputOptions, disabled, htmlHandler, cssHandler, jsHandler, preProcessJs } = getOptions(options);
214
- if (disabled) {
113
+ const ctx = new Context(options);
114
+ if (ctx.options.disabled) {
215
115
  return {
216
116
  name: pluginName
217
117
  };
@@ -220,18 +120,18 @@ const unplugin = createUnplugin((options = {}) => {
220
120
  name: pluginName,
221
121
  enforce: "pre",
222
122
  async buildStart() {
223
- await initConfig();
123
+ await ctx.initConfig();
224
124
  },
225
125
  transformInclude(id) {
226
- return isInclude(id);
126
+ return ctx.isInclude(id);
227
127
  },
228
128
  transform(code, id) {
229
- const replaceMap = getReplaceMap();
230
- if (id.endsWith(".js") || id.endsWith(".ts") || id.endsWith(".tsx") || id.endsWith(".jsx")) {
129
+ const replaceMap = ctx.getReplaceMap();
130
+ if (/\.[jt]sx?$/.test(id)) {
231
131
  const str = preProcessJs({
232
132
  code,
233
133
  replaceMap,
234
- addToUsedBy,
134
+ addToUsedBy: ctx.addToUsedBy.bind(ctx),
235
135
  id
236
136
  });
237
137
  return str;
@@ -245,7 +145,7 @@ const unplugin = createUnplugin((options = {}) => {
245
145
  vite: {
246
146
  generateBundle: {
247
147
  async handler(options2, bundle) {
248
- const replaceMap = getReplaceMap();
148
+ const replaceMap = ctx.getReplaceMap();
249
149
  const groupedEntries = getGroupedEntries(Object.entries(bundle));
250
150
  if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
251
151
  for (let i = 0; i < groupedEntries.css.length; i++) {
@@ -253,7 +153,7 @@ const unplugin = createUnplugin((options = {}) => {
253
153
  const { css } = await cssHandler(cssSource.source.toString(), {
254
154
  file,
255
155
  replaceMap,
256
- classGenerator
156
+ classGenerator: ctx.classGenerator
257
157
  });
258
158
  cssSource.source = css;
259
159
  }
@@ -271,14 +171,14 @@ const unplugin = createUnplugin((options = {}) => {
271
171
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
272
172
  },
273
173
  async (assets) => {
274
- const replaceMap = getReplaceMap();
174
+ const replaceMap = ctx.getReplaceMap();
275
175
  const groupedEntries = getGroupedEntries(Object.entries(assets));
276
176
  if (groupedEntries.js.length > 0) {
277
177
  for (let i = 0; i < groupedEntries.js.length; i++) {
278
178
  const [file, chunk] = groupedEntries.js[i];
279
179
  const code = jsHandler(chunk.source().toString(), {
280
180
  replaceMap,
281
- classGenerator
181
+ classGenerator: ctx.classGenerator
282
182
  }).code;
283
183
  if (code) {
284
184
  const source = new ConcatSource(code);
@@ -292,7 +192,7 @@ const unplugin = createUnplugin((options = {}) => {
292
192
  const { css } = await cssHandler(cssSource.source().toString(), {
293
193
  replaceMap,
294
194
  file,
295
- classGenerator
195
+ classGenerator: ctx.classGenerator
296
196
  });
297
197
  const source = new ConcatSource(css);
298
198
  compilation.updateAsset(file, source);
@@ -302,7 +202,7 @@ const unplugin = createUnplugin((options = {}) => {
302
202
  for (let i = 0; i < groupedEntries.html.length; i++) {
303
203
  const [file, asset] = groupedEntries.html[i];
304
204
  const html = htmlHandler(asset.source().toString(), {
305
- classGenerator,
205
+ classGenerator: ctx.classGenerator,
306
206
  replaceMap
307
207
  });
308
208
  const source = new ConcatSource(html);
@@ -313,20 +213,29 @@ const unplugin = createUnplugin((options = {}) => {
313
213
  );
314
214
  });
315
215
  },
316
- writeBundle() {
317
- const entries = Object.entries(classGenerator.newClassMap);
318
- if (entries.length > 0 && classMapOutputOptions) {
319
- cacheDump(
320
- classMapOutputOptions.filename,
321
- entries.map((x) => {
322
- return {
323
- origin: x[0],
324
- replacement: x[1].name,
325
- usedBy: [...x[1].usedBy]
326
- };
327
- }),
328
- classMapOutputOptions.dir
329
- );
216
+ async writeBundle() {
217
+ if (ctx.options.classMapOutput?.enable) {
218
+ const opts = ctx.options.classMapOutput;
219
+ const entries = Object.entries(ctx.classGenerator.newClassMap);
220
+ if (entries.length > 0 && opts) {
221
+ 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"
236
+ );
237
+ console.log(`\u2728 ${opts.filename} generated!`);
238
+ }
330
239
  }
331
240
  }
332
241
  };
package/dist/nuxt.cjs CHANGED
@@ -6,16 +6,18 @@ require('node:path');
6
6
  require('@tailwindcss-mangle/shared');
7
7
  require('@tailwindcss-mangle/config');
8
8
  require('fast-sort');
9
- require('@tailwindcss-mangle/core');
9
+ require('node:fs/promises');
10
10
  require('micromatch');
11
11
  require('unplugin');
12
+ require('@tailwindcss-mangle/core');
13
+ require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
14
 
13
15
  function nuxt(options = {}, nuxt) {
14
- nuxt.hook("webpack:config", async (config) => {
16
+ nuxt.hook("webpack:config", (config) => {
15
17
  config.plugins = config.plugins || [];
16
18
  config.plugins.unshift(index.webpack(options));
17
19
  });
18
- nuxt.hook("vite:extendConfig", async (config) => {
20
+ nuxt.hook("vite:extendConfig", (config) => {
19
21
  config.plugins = config.plugins || [];
20
22
  config.plugins.push(index.vite(options));
21
23
  });
package/dist/nuxt.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { O as Options } from './types-3f814672.js';
2
- import '@tailwindcss-mangle/shared';
1
+ import { MangleUserConfig } from '@tailwindcss-mangle/config';
3
2
 
4
- declare function export_default(options: Options | undefined, nuxt: any): void;
3
+ declare function export_default(options: MangleUserConfig | undefined, nuxt: any): void;
5
4
 
6
5
  export { export_default as default };
package/dist/nuxt.mjs CHANGED
@@ -4,16 +4,18 @@ import 'node:path';
4
4
  import '@tailwindcss-mangle/shared';
5
5
  import '@tailwindcss-mangle/config';
6
6
  import 'fast-sort';
7
- import '@tailwindcss-mangle/core';
7
+ import 'node:fs/promises';
8
8
  import 'micromatch';
9
9
  import 'unplugin';
10
+ import '@tailwindcss-mangle/core';
11
+ import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
12
 
11
13
  function nuxt(options = {}, nuxt) {
12
- nuxt.hook("webpack:config", async (config) => {
14
+ nuxt.hook("webpack:config", (config) => {
13
15
  config.plugins = config.plugins || [];
14
16
  config.plugins.unshift(unplugin.webpack(options));
15
17
  });
16
- nuxt.hook("vite:extendConfig", async (config) => {
18
+ nuxt.hook("vite:extendConfig", (config) => {
17
19
  config.plugins = config.plugins || [];
18
20
  config.plugins.push(unplugin.vite(options));
19
21
  });
package/dist/rollup.cjs CHANGED
@@ -6,9 +6,11 @@ require('node:path');
6
6
  require('@tailwindcss-mangle/shared');
7
7
  require('@tailwindcss-mangle/config');
8
8
  require('fast-sort');
9
- require('@tailwindcss-mangle/core');
9
+ require('node:fs/promises');
10
10
  require('micromatch');
11
11
  require('unplugin');
12
+ require('@tailwindcss-mangle/core');
13
+ require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
14
 
13
15
  const rollup = index.rollup;
14
16
 
package/dist/rollup.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as rollup from 'rollup';
2
- import { O as Options } from './types-3f814672.js';
3
- import '@tailwindcss-mangle/shared';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
4
3
 
5
- declare const _default: (options?: Options | undefined) => rollup.Plugin | rollup.Plugin[];
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => rollup.Plugin | rollup.Plugin[];
6
5
 
7
6
  export { _default as default };
package/dist/rollup.mjs CHANGED
@@ -4,9 +4,11 @@ import 'node:path';
4
4
  import '@tailwindcss-mangle/shared';
5
5
  import '@tailwindcss-mangle/config';
6
6
  import 'fast-sort';
7
- import '@tailwindcss-mangle/core';
7
+ import 'node:fs/promises';
8
8
  import 'micromatch';
9
9
  import 'unplugin';
10
+ import '@tailwindcss-mangle/core';
11
+ import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
12
 
11
13
  const rollup = unplugin.rollup;
12
14
 
@@ -0,0 +1,69 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import micromatch from 'micromatch';
4
+ import { groupBy } from '@tailwindcss-mangle/shared';
5
+
6
+ const pluginName = "unplugin-tailwindcss-mangle";
7
+
8
+ const { isMatch } = micromatch;
9
+ function getGroupedEntries(entries, options = {
10
+ cssMatcher(file) {
11
+ return /\.css$/.test(file);
12
+ },
13
+ htmlMatcher(file) {
14
+ return /\.html?$/.test(file);
15
+ },
16
+ jsMatcher(file) {
17
+ return /\.[cm]?js$/.test(file);
18
+ }
19
+ }) {
20
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
21
+ const groupedEntries = groupBy(entries, ([file]) => {
22
+ if (cssMatcher(file)) {
23
+ return "css";
24
+ } else if (htmlMatcher(file)) {
25
+ return "html";
26
+ } else if (jsMatcher(file)) {
27
+ return "js";
28
+ } else {
29
+ return "other";
30
+ }
31
+ });
32
+ if (!groupedEntries.css) {
33
+ groupedEntries.css = [];
34
+ }
35
+ if (!groupedEntries.html) {
36
+ groupedEntries.html = [];
37
+ }
38
+ if (!groupedEntries.js) {
39
+ groupedEntries.js = [];
40
+ }
41
+ if (!groupedEntries.other) {
42
+ groupedEntries.other = [];
43
+ }
44
+ return groupedEntries;
45
+ }
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
+ function getCacheDir(basedir = process.cwd()) {
57
+ return path.resolve(basedir, "node_modules/.cache", pluginName);
58
+ }
59
+ async function ensureDir(p) {
60
+ try {
61
+ await fs.access(p);
62
+ } catch {
63
+ await fs.mkdir(p, {
64
+ recursive: true
65
+ });
66
+ }
67
+ }
68
+
69
+ export { getCacheDir as a, createGlobMatcher as c, ensureDir as e, getGroupedEntries as g, pluginName as p };
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ const fs = require('node:fs/promises');
4
+ const path = require('node:path');
5
+ const micromatch = require('micromatch');
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 micromatch__default = /*#__PURE__*/_interopDefaultCompat(micromatch);
13
+
14
+ const pluginName = "unplugin-tailwindcss-mangle";
15
+
16
+ const { isMatch } = micromatch__default;
17
+ function getGroupedEntries(entries, options = {
18
+ cssMatcher(file) {
19
+ return /\.css$/.test(file);
20
+ },
21
+ htmlMatcher(file) {
22
+ return /\.html?$/.test(file);
23
+ },
24
+ jsMatcher(file) {
25
+ return /\.[cm]?js$/.test(file);
26
+ }
27
+ }) {
28
+ const { cssMatcher, htmlMatcher, jsMatcher } = options;
29
+ const groupedEntries = shared.groupBy(entries, ([file]) => {
30
+ if (cssMatcher(file)) {
31
+ return "css";
32
+ } else if (htmlMatcher(file)) {
33
+ return "html";
34
+ } else if (jsMatcher(file)) {
35
+ return "js";
36
+ } else {
37
+ return "other";
38
+ }
39
+ });
40
+ if (!groupedEntries.css) {
41
+ groupedEntries.css = [];
42
+ }
43
+ if (!groupedEntries.html) {
44
+ groupedEntries.html = [];
45
+ }
46
+ if (!groupedEntries.js) {
47
+ groupedEntries.js = [];
48
+ }
49
+ if (!groupedEntries.other) {
50
+ groupedEntries.other = [];
51
+ }
52
+ return groupedEntries;
53
+ }
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
+ function getCacheDir(basedir = process.cwd()) {
65
+ return path__default.resolve(basedir, "node_modules/.cache", pluginName);
66
+ }
67
+ async function ensureDir(p) {
68
+ try {
69
+ await fs__default.access(p);
70
+ } catch {
71
+ await fs__default.mkdir(p, {
72
+ recursive: true
73
+ });
74
+ }
75
+ }
76
+
77
+ exports.createGlobMatcher = createGlobMatcher;
78
+ exports.ensureDir = ensureDir;
79
+ exports.getCacheDir = getCacheDir;
80
+ exports.getGroupedEntries = getGroupedEntries;
81
+ exports.pluginName = pluginName;
package/dist/utils.cjs ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ require('node:fs/promises');
4
+ require('node:path');
5
+ require('micromatch');
6
+ const shared = require('@tailwindcss-mangle/shared');
7
+ const utils = require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
8
+
9
+
10
+
11
+ exports.defaultMangleClassFilter = shared.defaultMangleClassFilter;
12
+ exports.isMap = shared.isMap;
13
+ exports.isRegexp = shared.isRegexp;
14
+ exports.createGlobMatcher = utils.createGlobMatcher;
15
+ exports.ensureDir = utils.ensureDir;
16
+ exports.getCacheDir = utils.getCacheDir;
17
+ exports.getGroupedEntries = utils.getGroupedEntries;
@@ -0,0 +1,12 @@
1
+ export { defaultMangleClassFilter, isMap, isRegexp } from '@tailwindcss-mangle/shared';
2
+
3
+ declare function getGroupedEntries<T>(entries: [string, T][], options?: {
4
+ cssMatcher(file: string): boolean;
5
+ htmlMatcher(file: string): boolean;
6
+ jsMatcher(file: string): boolean;
7
+ }): Record<"css" | "html" | "js" | "other", [string, T][]>;
8
+ declare function createGlobMatcher(pattern: string | string[] | undefined, fallbackValue?: boolean): (file: string) => boolean;
9
+ declare function getCacheDir(basedir?: string): string;
10
+ declare function ensureDir(p: string): Promise<void>;
11
+
12
+ export { createGlobMatcher, ensureDir, getCacheDir, getGroupedEntries };
package/dist/utils.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import 'node:fs/promises';
2
+ import 'node:path';
3
+ import 'micromatch';
4
+ 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';
package/dist/vite.cjs CHANGED
@@ -6,9 +6,11 @@ require('node:path');
6
6
  require('@tailwindcss-mangle/shared');
7
7
  require('@tailwindcss-mangle/config');
8
8
  require('fast-sort');
9
- require('@tailwindcss-mangle/core');
9
+ require('node:fs/promises');
10
10
  require('micromatch');
11
11
  require('unplugin');
12
+ require('@tailwindcss-mangle/core');
13
+ require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
14
 
13
15
  const vite = index.vite;
14
16
 
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as vite from 'vite';
2
- import { O as Options } from './types-3f814672.js';
3
- import '@tailwindcss-mangle/shared';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
4
3
 
5
- declare const _default: (options?: Options | undefined) => vite.Plugin | vite.Plugin[];
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => vite.Plugin | vite.Plugin[];
6
5
 
7
6
  export { _default as default };
package/dist/vite.mjs CHANGED
@@ -4,9 +4,11 @@ import 'node:path';
4
4
  import '@tailwindcss-mangle/shared';
5
5
  import '@tailwindcss-mangle/config';
6
6
  import 'fast-sort';
7
- import '@tailwindcss-mangle/core';
7
+ import 'node:fs/promises';
8
8
  import 'micromatch';
9
9
  import 'unplugin';
10
+ import '@tailwindcss-mangle/core';
11
+ import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
12
 
11
13
  const vite = unplugin.vite;
12
14
 
package/dist/webpack.cjs CHANGED
@@ -6,9 +6,11 @@ require('node:path');
6
6
  require('@tailwindcss-mangle/shared');
7
7
  require('@tailwindcss-mangle/config');
8
8
  require('fast-sort');
9
- require('@tailwindcss-mangle/core');
9
+ require('node:fs/promises');
10
10
  require('micromatch');
11
11
  require('unplugin');
12
+ require('@tailwindcss-mangle/core');
13
+ require('./shared/unplugin-tailwindcss-mangle.e90953c3.cjs');
12
14
 
13
15
  const webpack = index.webpack;
14
16
 
package/dist/webpack.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
- import { O as Options } from './types-3f814672.js';
3
- import '@tailwindcss-mangle/shared';
2
+ import * as _tailwindcss_mangle_config_index from '@tailwindcss-mangle/config/index';
4
3
 
5
- declare const _default: (options?: Options | undefined) => webpack.WebpackPluginInstance;
4
+ declare const _default: (options: _tailwindcss_mangle_config_index.MangleUserConfig) => webpack.WebpackPluginInstance;
6
5
 
7
6
  export { _default as default };
package/dist/webpack.mjs CHANGED
@@ -4,9 +4,11 @@ import 'node:path';
4
4
  import '@tailwindcss-mangle/shared';
5
5
  import '@tailwindcss-mangle/config';
6
6
  import 'fast-sort';
7
- import '@tailwindcss-mangle/core';
7
+ import 'node:fs/promises';
8
8
  import 'micromatch';
9
9
  import 'unplugin';
10
+ import '@tailwindcss-mangle/core';
11
+ import './shared/unplugin-tailwindcss-mangle.bbd58ece.mjs';
10
12
 
11
13
  const webpack = unplugin.webpack;
12
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "2.0.2",
3
+ "version": "2.0.6",
4
4
  "description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -36,6 +36,11 @@
36
36
  "require": "./dist/nuxt.cjs",
37
37
  "import": "./dist/nuxt.mjs"
38
38
  },
39
+ "./utils": {
40
+ "types": "./dist/utils.d.ts",
41
+ "require": "./dist/utils.cjs",
42
+ "import": "./dist/utils.mjs"
43
+ },
39
44
  "./*": "./*"
40
45
  },
41
46
  "typesVersions": {
@@ -63,9 +68,9 @@
63
68
  "fast-sort": "^3.4.0",
64
69
  "micromatch": "^4.0.5",
65
70
  "unplugin": "^1.4.0",
66
- "@tailwindcss-mangle/config": "^1.0.1",
67
- "@tailwindcss-mangle/core": "^2.0.2",
68
- "@tailwindcss-mangle/shared": "^2.0.0"
71
+ "@tailwindcss-mangle/config": "^2.0.4",
72
+ "@tailwindcss-mangle/core": "^2.0.6",
73
+ "@tailwindcss-mangle/shared": "^2.0.4"
69
74
  },
70
75
  "publishConfig": {
71
76
  "access": "public",
@@ -83,7 +88,7 @@
83
88
  "vite": "^4.4.9",
84
89
  "webpack": "^5.88.2",
85
90
  "webpack-build-utils": "^0.0.4",
86
- "tailwindcss-patch": "^2.0.3"
91
+ "tailwindcss-patch": "^2.0.4"
87
92
  },
88
93
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",
89
94
  "repository": {
@@ -92,7 +97,7 @@
92
97
  },
93
98
  "scripts": {
94
99
  "build": "unbuild",
95
- "test": "vitest run",
100
+ "test": "vitest run --coverage.enabled",
96
101
  "test:dev": "vitest"
97
102
  }
98
103
  }
@@ -1,17 +0,0 @@
1
- import { IClassGeneratorOptions } from '@tailwindcss-mangle/shared';
2
-
3
- interface ClassMapOutputOptions {
4
- filename: string;
5
- dir?: string;
6
- }
7
- interface Options {
8
- mangleClassFilter?: (className: string) => boolean;
9
- classGenerator?: IClassGeneratorOptions;
10
- exclude?: string[];
11
- include?: string[];
12
- classListPath?: string;
13
- classMapOutput?: boolean | ClassMapOutputOptions;
14
- disabled?: boolean;
15
- }
16
-
17
- export { Options as O };