soranoo / next-css-obfuscator

A package deeply inspired by PostCSS-Obfuscator but for Next.js.
https://next-css-obfuscator.vercel.app
MIT License
71 stars 3 forks source link

[BUG] Incorrect: `className` detect to `property's name` in useRef #24

Closed hoangnhan2ka3 closed 6 months ago

hoangnhan2ka3 commented 6 months ago

Type

Checklist

  1. [x] Updated the package to the latest version
  2. [x] Read all documentation
  3. [x] No related issue
  4. [x] Meaningful issue title

Environment

Describe the bug transform property's name was obfuscated although it's not a className.

To Reproduce ...

Expected behavior This is not a className so don't obfuscate it.

Screenshots

Screenshot 2024-02-18 201306

Config

module.exports = {
  enable: true,
  mode: "random",
  buildFolderPath: ".next",
  classConversionJsonFolderPath: "./css-obfuscator",
  refreshClassConversionJson: false,

  classLength: 6,
  classPrefix: "n",
  classSuffix: "",

  classIgnore: ["no-transition", "opa-hidden", /nprogress*/, /__.*/, /os-*/],

  allowExtensions: [".jsx", ".tsx", ".js", ".ts", ".html", ".rsc"],

  contentIgnoreRegexes: [/\.jsxs\)\("\w+"/g],

  whiteListedFolderPaths: [],

  blackListedFolderPaths: ["./.next/cache", "./src", "./public", "./tests"],

  enableMarkers: false,
  markers: ["obf"],
  removeMarkersAfterObfuscated: true,

  removeOriginalCss: true,

  generatorSeed: "84817818898",

  //! Experimental feature (Alpha)
  enableJsAst: false,

  logLevel: "info",
};

Related files

Obfuscated version: 97fb199871848870.css.txt

Withoutobfuscated version: 97fb199871848870.css.txt

Demos (if any) N/A

Additional context

In conversion.json:

Screenshot 2024-02-18 201226

After npm run build + start

Screenshot 2024-02-18 201306

Others:

Screenshot 2024-02-18 201506 Screenshot 2024-02-18 201549
soranoo commented 6 months ago

As a temporary solution, add the following to the config

classIgnore = ["transform "]

I will get back to the issue after a month.

soranoo commented 6 months ago

I would say it is the limitation of the non-AST method. You may turn on the enableJsAst or make use of the temporary solution mentioned above.