Skip to content

Commit 9ff1d89

Browse files
committed
Incorporate original localName in generated class name
Also use git head sha (if available) to have value be deterministic, yet unstable
1 parent 1ff7364 commit 9ff1d89

File tree

1 file changed

+11
-3
lines changed
  • packages/calypso-build/webpack

1 file changed

+11
-3
lines changed

packages/calypso-build/webpack/sass.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
const { execSync } = require( 'node:child_process' );
12
const { createHash } = require( 'node:crypto' );
23
const WebpackRTLPlugin = require( '@automattic/webpack-rtl-plugin' );
34
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
45
const MiniCSSWithRTLPlugin = require( './mini-css-with-rtl' );
56

7+
/** @type {string | undefined} */
8+
let gitHeadSha;
9+
try {
10+
gitHeadSha = execSync( 'git rev-parse HEAD' ).toString();
11+
} catch {}
12+
613
/**
714
* Return a webpack loader object containing our styling (Sass -> CSS) stack.
815
* @param {Object} _ Options
@@ -23,12 +30,13 @@ module.exports.loader = ( { includePaths, prelude, postCssOptions, extract = tru
2330
modules: {
2431
exportOnlyLocals: ! extract,
2532
auto: /\.module\.s?css$/,
26-
getLocalIdent: ( context, localIdentName, localName ) =>
33+
getLocalIdent: ( _context, _localIdentName, localName ) =>
34+
localName +
2735
'_' +
2836
createHash( 'md5' )
29-
.update( context.resourcePath + localName )
37+
.update( localName + gitHeadSha )
3038
.digest( 'hex' )
31-
.substr( 0, 10 ),
39+
.slice( 0, 5 ),
3240
},
3341
// We do not want css-loader to resolve absolute paths. We
3442
// typically use `/` to indicate the start of the base URL,

0 commit comments

Comments
 (0)