From d7ace5bc6d6f0ee0927d14fa0cad2c67d1dcaf13 Mon Sep 17 00:00:00 2001 From: Stanley Chen Date: Tue, 23 Apr 2019 12:19:59 -0400 Subject: [PATCH 1/2] Change cssmodule classname hash to use repo relative paths instead of system absolute paths --- packages/react-dev-utils/getCSSModuleLocalIdent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/getCSSModuleLocalIdent.js b/packages/react-dev-utils/getCSSModuleLocalIdent.js index 504bb1581e1..3895e8f20c1 100644 --- a/packages/react-dev-utils/getCSSModuleLocalIdent.js +++ b/packages/react-dev-utils/getCSSModuleLocalIdent.js @@ -23,7 +23,7 @@ module.exports = function getLocalIdent( : '[name]'; // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique. const hash = loaderUtils.getHashDigest( - context.resourcePath + localName, + context.resourcePath.replace(context.rootContext, '') + localName, 'md5', 'base64', 5 From f423fc9bcb987c2d301431486456ac2a1e97e1ab Mon Sep 17 00:00:00 2001 From: Stanley Chen Date: Tue, 23 Apr 2019 17:52:20 -0400 Subject: [PATCH 2/2] switch to using path.posix.relative instead of string replace for project relative paths used in css module hashing --- packages/react-dev-utils/getCSSModuleLocalIdent.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/getCSSModuleLocalIdent.js b/packages/react-dev-utils/getCSSModuleLocalIdent.js index 3895e8f20c1..1b1ecf7695b 100644 --- a/packages/react-dev-utils/getCSSModuleLocalIdent.js +++ b/packages/react-dev-utils/getCSSModuleLocalIdent.js @@ -8,6 +8,7 @@ 'use strict'; const loaderUtils = require('loader-utils'); +const path = require('path'); module.exports = function getLocalIdent( context, @@ -23,7 +24,7 @@ module.exports = function getLocalIdent( : '[name]'; // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique. const hash = loaderUtils.getHashDigest( - context.resourcePath.replace(context.rootContext, '') + localName, + path.posix.relative(context.rootContext, context.resourcePath) + localName, 'md5', 'base64', 5