soranoo / next-css-obfuscator

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

Error: ENOENT: no such file or directory, scandir './css-obfuscator' #3

Closed sccofield closed 10 months ago

sccofield commented 10 months ago

Hey @soranoo, thank you so much for the beautiful work done so far.

At the moment, I used your settings as seen below. I can see that the tailwind classes have been obfuscated but i can't see the effect of the tailwind classes.

postcss.config.js

const isObfscMode = process.env.NODE_ENV === 'obfuscation';

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
    'next-css-obfuscator/patched-postcss-obfuscator': {
      enable: isObfscMode,
      extensions: ['.jsx', '.tsx', '.js', '.ts', '.html'],
      formatJson: true, // 👈 must be true
      keepData: true, // 👈 must be true
      whiteListedPaths: [],
      blackListedPaths: ['./next/cache'],
      excludeAnyMatchRegex: [
        /\.next\/server\/pages\/api/,
        /_document..*js/,
        /_app-.*/,
      ],
      classIgnore: ['static'],
      callBack: function () {
        // @ts-ignore
        process.env.NODE_ENV = 'production'; // to make sure postcss-obfuscator doesn't re-run.
      },
    },
  },
};
Screenshot 2024-01-10 at 5 32 44 AM
soranoo commented 10 months ago

Do you mean the page is broken after obfuscation?

sccofield commented 10 months ago

yea @soranoo the page is broken, the tailwind styles don't reflect on the page.

I tried starting the process all over on another branch but i am now getting this error when i run the obfuscate-build command

Error: ENOENT: no such file or directory, scandir './css-obfuscator'

soranoo commented 10 months ago

Which OS are you using?

sccofield commented 10 months ago

macbook

soranoo commented 10 months ago

I don't have any Apply device. I can't debug the issue but you may create the folder yourself and see what happens next.


root folder
|
|_  src
|_ css-obfuscator
sccofield commented 10 months ago

After creating the folder css-obfuscator, and running npm run obfuscate-build, it tells me Obfuscation Obfuscation complete , but no file is created in the folder.

soranoo commented 10 months ago

I have totally no idea why this happened. It works perfectly in my Docker Linux.

soranoo commented 10 months ago

Finally, I got the error.

To address this,

  1. If there are 2 postcss.config remove the one end with .js.

image

soranoo commented 10 months ago

v.2.0.0 has been released.

soranoo commented 10 months ago

The issue will be closed, please open a new one if encounter it again.