Skip to content

Commit 2b28b06

Browse files
authored
fix(core): always use hash for CSS module class names (#10423)
1 parent 97bd815 commit 2b28b06

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/docusaurus/src/webpack/base.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ export async function createBaseConfig({
231231
test: CSS_MODULE_REGEX,
232232
use: getStyleLoaders(isServer, {
233233
modules: {
234-
localIdentName: isProd
235-
? `[local]_[contenthash:base64:4]`
236-
: `[local]_[path][name]`,
234+
// Using the same CSS Module class pattern in dev/prod on purpose
235+
// See https://github.com/facebook/docusaurus/pull/10423
236+
localIdentName: `[local]_[contenthash:base64:4]`,
237237
exportOnlyLocals: isServer,
238238
},
239239
importLoaders: 1,

website/docs/styling-layout.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ If you want to add CSS to any element, you can open the DevTools in your browser
6363

6464
- **Theme class names**. These class names are listed exhaustively in [the next subsection](#theme-class-names). They don't have any default properties. You should always prioritize targeting those stable class names in your custom CSS.
6565
- **Infima class names**. These class names are found in the classic theme and usually follow the [BEM convention](http://getbem.com/naming/) of `block__element--modifier`. They are usually stable but are still considered implementation details, so you should generally avoid targeting them. However, you can [modify Infima CSS variables](#styling-your-site-with-infima).
66-
- **CSS module class names**. These class names have a hash in production (`codeBlockContainer_RIuc`) and are appended with a long file path in development. They are considered implementation details and you should almost always avoid targeting them in your custom CSS. If you must, you can use an [attribute selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) (`[class*='codeBlockContainer']`) that ignores the hash.
66+
- **CSS module class names**. These class names end with a hash which may change over time (`codeBlockContainer_RIuc`). They are considered implementation details and you should almost always avoid targeting them in your custom CSS. If you must, you can use an [attribute selector](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) (`[class*='codeBlockContainer']`) that ignores the hash.
6767

6868
### Theme Class Names {#theme-class-names}
6969

0 commit comments

Comments
 (0)