unplugin-tailwindcss-mangle 1.2.2 → 1.2.4
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.js +2 -2
- package/dist/esbuild.mjs +2 -2
- package/dist/index.js +35 -35
- package/dist/index.mjs +35 -35
- package/dist/nuxt.js +2 -2
- package/dist/nuxt.mjs +2 -2
- package/dist/rollup.js +2 -2
- package/dist/rollup.mjs +2 -2
- package/dist/types.d.ts +5 -8
- package/dist/utils.d.ts +1 -2
- package/dist/vite.js +2 -2
- package/dist/vite.mjs +2 -2
- package/dist/webpack.js +2 -2
- package/dist/webpack.mjs +2 -2
- package/package.json +4 -4
package/dist/esbuild.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
5
|
require('micromatch');
|
|
6
|
-
require('fs');
|
|
7
|
-
require('path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:path');
|
|
8
8
|
require('tailwindcss-mangle-shared');
|
|
9
9
|
require('tailwindcss-mangle-core');
|
|
10
10
|
require('tailwindcss-patch');
|
package/dist/esbuild.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var unplugin$1 = require('unplugin');
|
|
6
6
|
var micromatch = require('micromatch');
|
|
7
|
-
var fs = require('fs');
|
|
8
|
-
var path = require('path');
|
|
7
|
+
var fs = require('node:fs');
|
|
8
|
+
var path = require('node:path');
|
|
9
9
|
var tailwindcssMangleShared = require('tailwindcss-mangle-shared');
|
|
10
10
|
var tailwindcssMangleCore = require('tailwindcss-mangle-core');
|
|
11
11
|
var tailwindcssPatch = require('tailwindcss-patch');
|
|
@@ -60,7 +60,7 @@ function getGroupedEntries(entries, options = {
|
|
|
60
60
|
return groupedEntries;
|
|
61
61
|
}
|
|
62
62
|
function createGlobMatcher(pattern, fallbackValue = false) {
|
|
63
|
-
if (
|
|
63
|
+
if (pattern === undefined) {
|
|
64
64
|
return function (file) {
|
|
65
65
|
return fallbackValue;
|
|
66
66
|
};
|
|
@@ -85,7 +85,7 @@ function mkCacheDirectory(cwd = process.cwd()) {
|
|
|
85
85
|
function cacheDump(filename, data, basedir) {
|
|
86
86
|
try {
|
|
87
87
|
const dir = mkCacheDirectory(basedir);
|
|
88
|
-
fs__default["default"].writeFileSync(path__default["default"].resolve(dir, filename), JSON.stringify(
|
|
88
|
+
fs__default["default"].writeFileSync(path__default["default"].resolve(dir, filename), JSON.stringify([...data], undefined, 2), 'utf8');
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
91
|
console.log(error);
|
|
@@ -117,15 +117,15 @@ function getOptions(options = {}) {
|
|
|
117
117
|
const classGenerator = new tailwindcssMangleCore.ClassGenerator(options.classGenerator);
|
|
118
118
|
function getCachedClassSet() {
|
|
119
119
|
const set = twPatcher.getClassSet();
|
|
120
|
-
const isOutput = set.size && options.classSetOutput;
|
|
120
|
+
const isOutput = set.size > 0 && options.classSetOutput;
|
|
121
121
|
if (isOutput && classSetOutputOptions.type === 'all') {
|
|
122
122
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
for (const c of set) {
|
|
125
125
|
if (!currentMangleClassFilter(c)) {
|
|
126
126
|
set.delete(c);
|
|
127
127
|
}
|
|
128
|
-
}
|
|
128
|
+
}
|
|
129
129
|
if (isOutput && classSetOutputOptions.type === 'partial') {
|
|
130
130
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
131
131
|
}
|
|
@@ -157,11 +157,11 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
157
157
|
generateBundle: {
|
|
158
158
|
handler(options, bundle, isWrite) {
|
|
159
159
|
const runtimeSet = getCachedClassSet();
|
|
160
|
-
if (
|
|
160
|
+
if (runtimeSet.size === 0) {
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
const groupedEntries = getGroupedEntries(Object.entries(bundle));
|
|
164
|
-
if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
|
|
164
|
+
if (Array.isArray(groupedEntries.html) && groupedEntries.html.length > 0) {
|
|
165
165
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
166
166
|
const [file, asset] = groupedEntries.html[i];
|
|
167
167
|
if (isInclude(file)) {
|
|
@@ -173,7 +173,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
if (Array.isArray(groupedEntries.js) && groupedEntries.js.length) {
|
|
176
|
+
if (Array.isArray(groupedEntries.js) && groupedEntries.js.length > 0) {
|
|
177
177
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
178
178
|
const [file, chunk] = groupedEntries.js[i];
|
|
179
179
|
if (isInclude(file)) {
|
|
@@ -188,7 +188,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
if (Array.isArray(groupedEntries.css) && groupedEntries.css.length) {
|
|
191
|
+
if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
|
|
192
192
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
193
193
|
const [file, css] = groupedEntries.css[i];
|
|
194
194
|
if (isInclude(file)) {
|
|
@@ -214,7 +214,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
214
214
|
const abs = getAssetPath(outputPath, file);
|
|
215
215
|
const rel = getAssetPath(outputPath, file, false);
|
|
216
216
|
try {
|
|
217
|
-
fs__default["default"].writeFileSync(abs, data, '
|
|
217
|
+
fs__default["default"].writeFileSync(abs, data, 'utf8');
|
|
218
218
|
console.log('[tailwindcss-mangle]: ' + rel + ' overwrited successfully');
|
|
219
219
|
}
|
|
220
220
|
catch (error) {
|
|
@@ -244,20 +244,20 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
244
244
|
}, (assets) => {
|
|
245
245
|
const runtimeSet = getCachedClassSet();
|
|
246
246
|
const groupedEntries = getGroupedEntries(Object.entries(assets));
|
|
247
|
-
if (
|
|
247
|
+
if (runtimeSet.size === 0) {
|
|
248
248
|
const css = new Map();
|
|
249
249
|
const html = new Map();
|
|
250
250
|
const js = new Map();
|
|
251
|
-
|
|
251
|
+
for (const [file, source] of groupedEntries.css) {
|
|
252
252
|
css.set(file, source);
|
|
253
|
-
}
|
|
254
|
-
|
|
253
|
+
}
|
|
254
|
+
for (const [file, source] of groupedEntries.html) {
|
|
255
255
|
html.set(file, source);
|
|
256
|
-
}
|
|
257
|
-
|
|
256
|
+
}
|
|
257
|
+
for (const [file, source] of groupedEntries.js) {
|
|
258
258
|
js.set(file, source);
|
|
259
|
-
}
|
|
260
|
-
if (js.size || css.size || html.size) {
|
|
259
|
+
}
|
|
260
|
+
if (js.size > 0 || css.size > 0 || html.size > 0) {
|
|
261
261
|
outputCachedMap.set(compiler.outputPath, {
|
|
262
262
|
css,
|
|
263
263
|
html,
|
|
@@ -266,7 +266,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
266
266
|
}
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
|
-
if (groupedEntries.html.length) {
|
|
269
|
+
if (groupedEntries.html.length > 0) {
|
|
270
270
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
271
271
|
const [file, asset] = groupedEntries.html[i];
|
|
272
272
|
if (isInclude(file)) {
|
|
@@ -280,7 +280,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
if (groupedEntries.js.length) {
|
|
283
|
+
if (groupedEntries.js.length > 0) {
|
|
284
284
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
285
285
|
const [file, chunk] = groupedEntries.js[i];
|
|
286
286
|
if (isInclude(file)) {
|
|
@@ -296,7 +296,7 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
if (groupedEntries.css.length) {
|
|
299
|
+
if (groupedEntries.css.length > 0) {
|
|
300
300
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
301
301
|
const [file, css] = groupedEntries.css[i];
|
|
302
302
|
if (isInclude(file)) {
|
|
@@ -310,9 +310,9 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
|
|
314
|
-
if (html.size) {
|
|
315
|
-
html.
|
|
313
|
+
for (const [key, { js, html, css }] of outputCachedMap.entries()) {
|
|
314
|
+
if (html.size > 0) {
|
|
315
|
+
for (const [file, asset] of html.entries()) {
|
|
316
316
|
if (isInclude(file)) {
|
|
317
317
|
const html = tailwindcssMangleCore.htmlHandler(asset.source().toString(), {
|
|
318
318
|
...htmlHandlerOptions,
|
|
@@ -321,11 +321,11 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
321
321
|
});
|
|
322
322
|
overwriteServerSideAsset(key, file, html);
|
|
323
323
|
}
|
|
324
|
-
}
|
|
324
|
+
}
|
|
325
325
|
html.clear();
|
|
326
326
|
}
|
|
327
|
-
if (js.size) {
|
|
328
|
-
js.
|
|
327
|
+
if (js.size > 0) {
|
|
328
|
+
for (const [file, chunk] of js.entries()) {
|
|
329
329
|
if (isInclude(file)) {
|
|
330
330
|
const rawCode = chunk.source().toString();
|
|
331
331
|
const code = tailwindcssMangleCore.jsHandler(rawCode, {
|
|
@@ -337,11 +337,11 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
337
337
|
overwriteServerSideAsset(key, file, code);
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
}
|
|
340
|
+
}
|
|
341
341
|
js.clear();
|
|
342
342
|
}
|
|
343
|
-
if (css.size) {
|
|
344
|
-
css.
|
|
343
|
+
if (css.size > 0) {
|
|
344
|
+
for (const [file, style] of css.entries()) {
|
|
345
345
|
if (isInclude(file)) {
|
|
346
346
|
const newCss = tailwindcssMangleCore.cssHandler(style.source().toString(), {
|
|
347
347
|
...cssHandlerOptions,
|
|
@@ -350,16 +350,16 @@ const unplugin = unplugin$1.createUnplugin((options = {}, meta) => {
|
|
|
350
350
|
});
|
|
351
351
|
overwriteServerSideAsset(key, file, newCss);
|
|
352
352
|
}
|
|
353
|
-
}
|
|
353
|
+
}
|
|
354
354
|
css.clear();
|
|
355
355
|
}
|
|
356
|
-
}
|
|
356
|
+
}
|
|
357
357
|
});
|
|
358
358
|
});
|
|
359
359
|
},
|
|
360
360
|
writeBundle() {
|
|
361
361
|
const entries = Object.entries(classGenerator.newClassMap);
|
|
362
|
-
if (entries.length && classMapOutputOptions) {
|
|
362
|
+
if (entries.length > 0 && classMapOutputOptions) {
|
|
363
363
|
cacheDump(classMapOutputOptions.filename, entries.map((x) => {
|
|
364
364
|
return [x[0], x[1].name];
|
|
365
365
|
}), classMapOutputOptions.dir);
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createUnplugin } from 'unplugin';
|
|
2
2
|
import micromatch from 'micromatch';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
5
|
import { groupBy, defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
6
6
|
export { defaultMangleClassFilter } from 'tailwindcss-mangle-shared';
|
|
7
7
|
import { ClassGenerator, htmlHandler, jsHandler, cssHandler } from 'tailwindcss-mangle-core';
|
|
@@ -51,7 +51,7 @@ function getGroupedEntries(entries, options = {
|
|
|
51
51
|
return groupedEntries;
|
|
52
52
|
}
|
|
53
53
|
function createGlobMatcher(pattern, fallbackValue = false) {
|
|
54
|
-
if (
|
|
54
|
+
if (pattern === undefined) {
|
|
55
55
|
return function (file) {
|
|
56
56
|
return fallbackValue;
|
|
57
57
|
};
|
|
@@ -76,7 +76,7 @@ function mkCacheDirectory(cwd = process.cwd()) {
|
|
|
76
76
|
function cacheDump(filename, data, basedir) {
|
|
77
77
|
try {
|
|
78
78
|
const dir = mkCacheDirectory(basedir);
|
|
79
|
-
fs.writeFileSync(path.resolve(dir, filename), JSON.stringify(
|
|
79
|
+
fs.writeFileSync(path.resolve(dir, filename), JSON.stringify([...data], undefined, 2), 'utf8');
|
|
80
80
|
}
|
|
81
81
|
catch (error) {
|
|
82
82
|
console.log(error);
|
|
@@ -108,15 +108,15 @@ function getOptions(options = {}) {
|
|
|
108
108
|
const classGenerator = new ClassGenerator(options.classGenerator);
|
|
109
109
|
function getCachedClassSet() {
|
|
110
110
|
const set = twPatcher.getClassSet();
|
|
111
|
-
const isOutput = set.size && options.classSetOutput;
|
|
111
|
+
const isOutput = set.size > 0 && options.classSetOutput;
|
|
112
112
|
if (isOutput && classSetOutputOptions.type === 'all') {
|
|
113
113
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
for (const c of set) {
|
|
116
116
|
if (!currentMangleClassFilter(c)) {
|
|
117
117
|
set.delete(c);
|
|
118
118
|
}
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
if (isOutput && classSetOutputOptions.type === 'partial') {
|
|
121
121
|
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir);
|
|
122
122
|
}
|
|
@@ -148,11 +148,11 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
148
148
|
generateBundle: {
|
|
149
149
|
handler(options, bundle, isWrite) {
|
|
150
150
|
const runtimeSet = getCachedClassSet();
|
|
151
|
-
if (
|
|
151
|
+
if (runtimeSet.size === 0) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
const groupedEntries = getGroupedEntries(Object.entries(bundle));
|
|
155
|
-
if (Array.isArray(groupedEntries.html) && groupedEntries.html.length) {
|
|
155
|
+
if (Array.isArray(groupedEntries.html) && groupedEntries.html.length > 0) {
|
|
156
156
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
157
157
|
const [file, asset] = groupedEntries.html[i];
|
|
158
158
|
if (isInclude(file)) {
|
|
@@ -164,7 +164,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
if (Array.isArray(groupedEntries.js) && groupedEntries.js.length) {
|
|
167
|
+
if (Array.isArray(groupedEntries.js) && groupedEntries.js.length > 0) {
|
|
168
168
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
169
169
|
const [file, chunk] = groupedEntries.js[i];
|
|
170
170
|
if (isInclude(file)) {
|
|
@@ -179,7 +179,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
if (Array.isArray(groupedEntries.css) && groupedEntries.css.length) {
|
|
182
|
+
if (Array.isArray(groupedEntries.css) && groupedEntries.css.length > 0) {
|
|
183
183
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
184
184
|
const [file, css] = groupedEntries.css[i];
|
|
185
185
|
if (isInclude(file)) {
|
|
@@ -205,7 +205,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
205
205
|
const abs = getAssetPath(outputPath, file);
|
|
206
206
|
const rel = getAssetPath(outputPath, file, false);
|
|
207
207
|
try {
|
|
208
|
-
fs.writeFileSync(abs, data, '
|
|
208
|
+
fs.writeFileSync(abs, data, 'utf8');
|
|
209
209
|
console.log('[tailwindcss-mangle]: ' + rel + ' overwrited successfully');
|
|
210
210
|
}
|
|
211
211
|
catch (error) {
|
|
@@ -235,20 +235,20 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
235
235
|
}, (assets) => {
|
|
236
236
|
const runtimeSet = getCachedClassSet();
|
|
237
237
|
const groupedEntries = getGroupedEntries(Object.entries(assets));
|
|
238
|
-
if (
|
|
238
|
+
if (runtimeSet.size === 0) {
|
|
239
239
|
const css = new Map();
|
|
240
240
|
const html = new Map();
|
|
241
241
|
const js = new Map();
|
|
242
|
-
|
|
242
|
+
for (const [file, source] of groupedEntries.css) {
|
|
243
243
|
css.set(file, source);
|
|
244
|
-
}
|
|
245
|
-
|
|
244
|
+
}
|
|
245
|
+
for (const [file, source] of groupedEntries.html) {
|
|
246
246
|
html.set(file, source);
|
|
247
|
-
}
|
|
248
|
-
|
|
247
|
+
}
|
|
248
|
+
for (const [file, source] of groupedEntries.js) {
|
|
249
249
|
js.set(file, source);
|
|
250
|
-
}
|
|
251
|
-
if (js.size || css.size || html.size) {
|
|
250
|
+
}
|
|
251
|
+
if (js.size > 0 || css.size > 0 || html.size > 0) {
|
|
252
252
|
outputCachedMap.set(compiler.outputPath, {
|
|
253
253
|
css,
|
|
254
254
|
html,
|
|
@@ -257,7 +257,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
257
257
|
}
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
-
if (groupedEntries.html.length) {
|
|
260
|
+
if (groupedEntries.html.length > 0) {
|
|
261
261
|
for (let i = 0; i < groupedEntries.html.length; i++) {
|
|
262
262
|
const [file, asset] = groupedEntries.html[i];
|
|
263
263
|
if (isInclude(file)) {
|
|
@@ -271,7 +271,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
if (groupedEntries.js.length) {
|
|
274
|
+
if (groupedEntries.js.length > 0) {
|
|
275
275
|
for (let i = 0; i < groupedEntries.js.length; i++) {
|
|
276
276
|
const [file, chunk] = groupedEntries.js[i];
|
|
277
277
|
if (isInclude(file)) {
|
|
@@ -287,7 +287,7 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
if (groupedEntries.css.length) {
|
|
290
|
+
if (groupedEntries.css.length > 0) {
|
|
291
291
|
for (let i = 0; i < groupedEntries.css.length; i++) {
|
|
292
292
|
const [file, css] = groupedEntries.css[i];
|
|
293
293
|
if (isInclude(file)) {
|
|
@@ -301,9 +301,9 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
|
-
|
|
305
|
-
if (html.size) {
|
|
306
|
-
html.
|
|
304
|
+
for (const [key, { js, html, css }] of outputCachedMap.entries()) {
|
|
305
|
+
if (html.size > 0) {
|
|
306
|
+
for (const [file, asset] of html.entries()) {
|
|
307
307
|
if (isInclude(file)) {
|
|
308
308
|
const html = htmlHandler(asset.source().toString(), {
|
|
309
309
|
...htmlHandlerOptions,
|
|
@@ -312,11 +312,11 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
312
312
|
});
|
|
313
313
|
overwriteServerSideAsset(key, file, html);
|
|
314
314
|
}
|
|
315
|
-
}
|
|
315
|
+
}
|
|
316
316
|
html.clear();
|
|
317
317
|
}
|
|
318
|
-
if (js.size) {
|
|
319
|
-
js.
|
|
318
|
+
if (js.size > 0) {
|
|
319
|
+
for (const [file, chunk] of js.entries()) {
|
|
320
320
|
if (isInclude(file)) {
|
|
321
321
|
const rawCode = chunk.source().toString();
|
|
322
322
|
const code = jsHandler(rawCode, {
|
|
@@ -328,11 +328,11 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
328
328
|
overwriteServerSideAsset(key, file, code);
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
}
|
|
331
|
+
}
|
|
332
332
|
js.clear();
|
|
333
333
|
}
|
|
334
|
-
if (css.size) {
|
|
335
|
-
css.
|
|
334
|
+
if (css.size > 0) {
|
|
335
|
+
for (const [file, style] of css.entries()) {
|
|
336
336
|
if (isInclude(file)) {
|
|
337
337
|
const newCss = cssHandler(style.source().toString(), {
|
|
338
338
|
...cssHandlerOptions,
|
|
@@ -341,16 +341,16 @@ const unplugin = createUnplugin((options = {}, meta) => {
|
|
|
341
341
|
});
|
|
342
342
|
overwriteServerSideAsset(key, file, newCss);
|
|
343
343
|
}
|
|
344
|
-
}
|
|
344
|
+
}
|
|
345
345
|
css.clear();
|
|
346
346
|
}
|
|
347
|
-
}
|
|
347
|
+
}
|
|
348
348
|
});
|
|
349
349
|
});
|
|
350
350
|
},
|
|
351
351
|
writeBundle() {
|
|
352
352
|
const entries = Object.entries(classGenerator.newClassMap);
|
|
353
|
-
if (entries.length && classMapOutputOptions) {
|
|
353
|
+
if (entries.length > 0 && classMapOutputOptions) {
|
|
354
354
|
cacheDump(classMapOutputOptions.filename, entries.map((x) => {
|
|
355
355
|
return [x[0], x[1].name];
|
|
356
356
|
}), classMapOutputOptions.dir);
|
package/dist/nuxt.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
5
|
require('micromatch');
|
|
6
|
-
require('fs');
|
|
7
|
-
require('path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:path');
|
|
8
8
|
require('tailwindcss-mangle-shared');
|
|
9
9
|
require('tailwindcss-mangle-core');
|
|
10
10
|
require('tailwindcss-patch');
|
package/dist/nuxt.mjs
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
5
|
require('micromatch');
|
|
6
|
-
require('fs');
|
|
7
|
-
require('path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:path');
|
|
8
8
|
require('tailwindcss-mangle-shared');
|
|
9
9
|
require('tailwindcss-mangle-core');
|
|
10
10
|
require('tailwindcss-patch');
|
package/dist/rollup.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IHandlerOptions, IHtmlHandlerOptions, IJsHandlerOptions, ICssHandlerOptions } from 'tailwindcss-mangle-core';
|
|
2
2
|
export interface IClassGeneratorOptions {
|
|
3
3
|
reserveClassName?: (string | RegExp)[];
|
|
4
4
|
customGenerate?: (original: string, opts: IClassGeneratorOptions, context: Record<string, any>) => string | undefined;
|
|
@@ -8,10 +8,6 @@ export interface IClassGeneratorOptions {
|
|
|
8
8
|
ignoreClass?: (string | RegExp)[];
|
|
9
9
|
classPrefix?: string;
|
|
10
10
|
}
|
|
11
|
-
export interface IHandlerOptions {
|
|
12
|
-
runtimeSet: Set<string>;
|
|
13
|
-
classGenerator: ClassGenerator;
|
|
14
|
-
}
|
|
15
11
|
export interface ClassSetOutputOptions {
|
|
16
12
|
filename: string;
|
|
17
13
|
dir?: string;
|
|
@@ -21,6 +17,7 @@ export interface ClassMapOutputOptions {
|
|
|
21
17
|
filename: string;
|
|
22
18
|
dir?: string;
|
|
23
19
|
}
|
|
20
|
+
export type PartialHandlerOptions<T extends IHandlerOptions> = Partial<Omit<T, 'runtimeSet' | 'classGenerator'>>;
|
|
24
21
|
export interface Options {
|
|
25
22
|
mangleClassFilter?: (className: string) => boolean;
|
|
26
23
|
classGenerator?: IClassGeneratorOptions;
|
|
@@ -28,7 +25,7 @@ export interface Options {
|
|
|
28
25
|
include?: string[];
|
|
29
26
|
classSetOutput?: boolean | ClassSetOutputOptions;
|
|
30
27
|
classMapOutput?: boolean | ClassMapOutputOptions;
|
|
31
|
-
htmlHandlerOptions?: IHtmlHandlerOptions
|
|
32
|
-
jsHandlerOptions?: IJsHandlerOptions
|
|
33
|
-
cssHandlerOptions?: ICssHandlerOptions
|
|
28
|
+
htmlHandlerOptions?: PartialHandlerOptions<IHtmlHandlerOptions>;
|
|
29
|
+
jsHandlerOptions?: PartialHandlerOptions<IJsHandlerOptions>;
|
|
30
|
+
cssHandlerOptions?: PartialHandlerOptions<ICssHandlerOptions>;
|
|
34
31
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { defaultMangleClassFilter, isMap, isRegexp } from 'tailwindcss-mangle-shared';
|
|
2
|
-
export { defaultMangleClassFilter, isMap, isRegexp };
|
|
3
1
|
export declare function getGroupedEntries<T>(entries: [string, T][], options?: {
|
|
4
2
|
cssMatcher(file: string): boolean;
|
|
5
3
|
htmlMatcher(file: string): boolean;
|
|
@@ -9,3 +7,4 @@ export declare function createGlobMatcher(pattern: string | string[] | undefined
|
|
|
9
7
|
export declare function getCacheDir(basedir?: string): string;
|
|
10
8
|
export declare function mkCacheDirectory(cwd?: string): string;
|
|
11
9
|
export declare function cacheDump(filename: string, data: any[] | Set<any>, basedir?: string): void;
|
|
10
|
+
export { defaultMangleClassFilter, isMap, isRegexp } from 'tailwindcss-mangle-shared';
|
package/dist/vite.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
5
|
require('micromatch');
|
|
6
|
-
require('fs');
|
|
7
|
-
require('path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:path');
|
|
8
8
|
require('tailwindcss-mangle-shared');
|
|
9
9
|
require('tailwindcss-mangle-core');
|
|
10
10
|
require('tailwindcss-patch');
|
package/dist/vite.mjs
CHANGED
package/dist/webpack.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var index = require('./index.js');
|
|
4
4
|
require('unplugin');
|
|
5
5
|
require('micromatch');
|
|
6
|
-
require('fs');
|
|
7
|
-
require('path');
|
|
6
|
+
require('node:fs');
|
|
7
|
+
require('node:path');
|
|
8
8
|
require('tailwindcss-mangle-shared');
|
|
9
9
|
require('tailwindcss-mangle-core');
|
|
10
10
|
require('tailwindcss-patch');
|
package/dist/webpack.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-tailwindcss-mangle",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "mangle tailwindcss utilities class plugin. support vite and webpack!",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"micromatch": "^4.0.5",
|
|
64
64
|
"unplugin": "^1.3.1",
|
|
65
|
-
"tailwindcss-mangle-core": "^1.2.
|
|
66
|
-
"tailwindcss-mangle-shared": "^1.2.
|
|
67
|
-
"tailwindcss-patch": "^1.2.
|
|
65
|
+
"tailwindcss-mangle-core": "^1.2.4",
|
|
66
|
+
"tailwindcss-mangle-shared": "^1.2.4",
|
|
67
|
+
"tailwindcss-patch": "^1.2.4"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public",
|