unplugin-tailwindcss-mangle 0.0.4 → 0.0.5

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  mangle tailwindcss utilities plugin
4
4
 
5
- > Now Support `vite` and `webpack`
5
+ > Now Support `vite` and `webpack`(Experiment!)
6
6
 
7
7
  - [unplugin-tailwindcss-mangle](#unplugin-tailwindcss-mangle)
8
8
  - [Features](#features)
package/dist/index.js CHANGED
@@ -322,6 +322,9 @@ function getDefaultExportFromNamespaceIfPresent(n) {
322
322
  }
323
323
  const generate = getDefaultExportFromNamespaceIfPresent(_generate__default["default"]);
324
324
  const traverse = getDefaultExportFromNamespaceIfPresent(_traverse__default["default"]);
325
+ function makeRegex(str) {
326
+ return new RegExp('(?<=^|[\\s"])' + escapeStringRegexp(str), 'g');
327
+ }
325
328
  function handleValue(str, node, options) {
326
329
  const set = options.runtimeSet;
327
330
  const clsGen = options.classGenerator;
@@ -335,7 +338,7 @@ function handleValue(str, node, options) {
335
338
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
336
339
  }
337
340
  if (!ignoreFlag) {
338
- rawStr = rawStr.replace(new RegExp('(?<="|\\s)' + escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
341
+ rawStr = rawStr.replace(makeRegex(v), clsGen.generateClassName(v).name);
339
342
  }
340
343
  }
341
344
  }
package/dist/index.mjs CHANGED
@@ -311,6 +311,9 @@ function getDefaultExportFromNamespaceIfPresent(n) {
311
311
  }
312
312
  const generate = getDefaultExportFromNamespaceIfPresent(_generate);
313
313
  const traverse = getDefaultExportFromNamespaceIfPresent(_traverse);
314
+ function makeRegex(str) {
315
+ return new RegExp('(?<=^|[\\s"])' + escapeStringRegexp(str), 'g');
316
+ }
314
317
  function handleValue(str, node, options) {
315
318
  const set = options.runtimeSet;
316
319
  const clsGen = options.classGenerator;
@@ -324,7 +327,7 @@ function handleValue(str, node, options) {
324
327
  ignoreFlag = node.leadingComments.findIndex((x) => x.value.includes('tw-mangle') && x.value.includes('ignore')) > -1;
325
328
  }
326
329
  if (!ignoreFlag) {
327
- rawStr = rawStr.replace(new RegExp('(?<="|\\s)' + escapeStringRegexp(v), 'g'), clsGen.generateClassName(v).name);
330
+ rawStr = rawStr.replace(makeRegex(v), clsGen.generateClassName(v).name);
328
331
  }
329
332
  }
330
333
  }
@@ -1,4 +1,5 @@
1
1
  import type { StringLiteral, TemplateElement } from '@babel/types';
2
2
  import type { IHandlerOptions } from '../types';
3
+ export declare function makeRegex(str: string): RegExp;
3
4
  export declare function handleValue(str: string, node: StringLiteral | TemplateElement, options: IHandlerOptions): string;
4
5
  export declare function jsHandler(rawSource: string, options: IHandlerOptions): import("@babel/generator").GeneratorResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-tailwindcss-mangle",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "mangle tailwindcss utilities class",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -48,7 +48,9 @@
48
48
  "tailwindcss",
49
49
  "utilities",
50
50
  "mangle",
51
- "class"
51
+ "class",
52
+ "obfuscator",
53
+ "obfuscation"
52
54
  ],
53
55
  "author": "SonOfMagic <qq1324318532@gmail.com>",
54
56
  "license": "MIT",