Sergei Basharov
Sergei Basharov

Reputation: 53830

How to give classes in CSS modules better names?

I have this config in webpack.config.js:

  {
    test: /\.css$/,
    use: [
      {loader: "style-loader"},
      {
        loader: "css-loader",
        options: {
          modules: true,
          importLoaders: 1,
          sourceMap: true
        }
      }
    ]
  }

It works as expected, but the one small thing can be improved - names of classes generated.

Is it possible to, say, add the generated string to the existing class name?

Like this:

// before:
   gSJW8QAdF0l_JiFWFeyjq

// after:
   loginContainer_gSJW8QAdF0l_JiFWFeyjq

Upvotes: 0

Views: 1369

Answers (1)

Pavel Denisjuk
Pavel Denisjuk

Reputation: 1473

Refer to the official docs and look for the section about localIdentName and getLocalIdent. Using that you can completely customize your class name. Cheers!

Upvotes: 3

Related Questions