Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to obfuscate CSS class names? #1773

Closed
jleei opened this issue Dec 1, 2021 · 6 comments
Closed

How to obfuscate CSS class names? #1773

jleei opened this issue Dec 1, 2021 · 6 comments

Comments

@jleei
Copy link

jleei commented Dec 1, 2021

e.g.

<div class="container"><div class="row"></div></div>

to:

<div class="j83agx80"><div class="cbu4d94t"></div></div>

change all css class names. Don't know much about the configuration of webpack, is it difficult to implement this function? use Webpack's css-loader?

@fivethreeo
Copy link
Collaborator

just rename the name.css -> name.module.css

@jleei
Copy link
Author

jleei commented Dec 1, 2021

ok, I tried to override razzle's config, but didn't work.

razzle.config.js:

module.exports = {
  plugins: [
    {
      name: 'scss',
      options: {
        postcss: {
          dev: {
            sourceMap: true,
            importLoaders: 1,
            modules: {
              auto: true,
              localIdentName: '[hash:base64:5]',
            },
          },
          prod: {
            sourceMap: true,
            importLoaders: 1,
            modules: {
              auto: true,
              localIdentName: '[hash:base64:5]',
            },
          },
        },
      },
    },
    'mdx',
  ],
};

changed localIdentName from [name]__[local]___[hash:base64:5] to [hash:base64:5]
but the compiled result was still 'ComponentName-module__name___2Dj4i' format.
What am i doing wrong?

@fivethreeo
Copy link
Collaborator

css not postcss

@jleei
Copy link
Author

jleei commented Dec 1, 2021

It works. Thanks for your help.

@fivethreeo
Copy link
Collaborator

resolved

@n4j1Br4ch1D
Copy link

Check out this postcss plugin:
https://www.npmjs.com/package/postcss-obfuscator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants