diff --git a/docusaurus/docs/advanced-configuration.md b/docusaurus/docs/advanced-configuration.md index 7cc9f14f888..3943463de07 100644 --- a/docusaurus/docs/advanced-configuration.md +++ b/docusaurus/docs/advanced-configuration.md @@ -23,6 +23,7 @@ You can adjust various development and production settings by setting environmen | REACT_EDITOR | βœ… Used | 🚫 Ignored | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebook/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH]() environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely. | | CHOKIDAR_USEPOLLING | βœ… Used | 🚫 Ignored | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. | | GENERATE_SOURCEMAP | 🚫 Ignored | βœ… Used | When set to `false`, source maps are not generated for a production build. This solves out of memory (OOM) issues on some smaller machines. | +| CSS_LOCAL_IDENT_NAME | βœ… Used | βœ… Used | When set to `false`, css modules don't generate full path to component in ident names (e.g. class names). Ident names obfuscated/minified, not readable. | | INLINE_RUNTIME_CHUNK | 🚫 Ignored | βœ… Used | By default, Create React App will embed the runtime script into `index.html` during the production build. When set to `false`, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP. | | IMAGE_INLINE_SIZE_LIMIT | βœ… Used | βœ… Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to `0` will disable the inlining of images. | | FAST_REFRESH | βœ… Used | 🚫 Ignored | When set to `false`, disables experimental support for Fast Refresh to allow you to tweak your components in real time without reloading the page. | diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 5e5f87f3ce9..0183b8b9a40 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -44,6 +44,8 @@ const appPackageJson = require(paths.appPackageJson); // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; +const shouldUseLocalIdentName = process.env.CSS_LOCAL_IDENT_NAME !== 'false'; + const webpackDevClientEntry = require.resolve( 'react-dev-utils/webpackHotDevClient' ); @@ -170,6 +172,11 @@ module.exports = function (webpackEnv) { return loaders; }; + const getCssModulesIdentNameConfig = () => + shouldUseLocalIdentName + ? { compileType: 'module', getLocalIdent: getCSSModuleLocalIdent } + : { compileType: 'module', localIdentName: '[hash:base64]' }; + return { mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development', // Stop compilation early in production @@ -537,10 +544,7 @@ module.exports = function (webpackEnv) { sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment, - modules: { - compileType: 'module', - getLocalIdent: getCSSModuleLocalIdent, - }, + modules: getCssModulesIdentNameConfig(), }), }, // Opt-in support for SASS (using .scss or .sass extensions). @@ -577,10 +581,7 @@ module.exports = function (webpackEnv) { sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment, - modules: { - compileType: 'module', - getLocalIdent: getCSSModuleLocalIdent, - }, + modules: getCssModulesIdentNameConfig(), }, 'sass-loader' ),