Skip to content

Commit 08207c0

Browse files
refactor: removed interpolateName in favor webpack template strings
1 parent 5536462 commit 08207c0

File tree

8 files changed

+1618
-1319
lines changed

8 files changed

+1618
-1319
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ module.exports = {
580580
mode: "local",
581581
auto: true,
582582
exportGlobals: true,
583-
localIdentName: "[path][name]__[local]--[hash:base64:5]",
583+
localIdentName: "[path][name]__[local]--[contenthash]",
584584
localIdentContext: path.resolve(__dirname, "src"),
585585
localIdentHashPrefix: "my-custom-hash",
586586
namedExport: true,
@@ -754,15 +754,31 @@ module.exports = {
754754
##### `localIdentName`
755755

756756
Type: `String`
757-
Default: `'[hash:base64]'`
757+
Default: `'[contenthash]'`
758758

759759
Allows to configure the generated local ident name.
760-
See [loader-utils's documentation](https://github.com/webpack/loader-utils#interpolatename) for more information on options.
760+
761+
For more information on options see:
762+
763+
- [webpack template strings](https://webpack.js.org/configuration/output/#template-strings),
764+
- [output.hashdigest](https://webpack.js.org/configuration/output/#outputhashdigest),
765+
- [output.hashDigestLength](https://webpack.js.org/configuration/output/#outputhashdigestlength),
766+
- [output.hashFunction](https://webpack.js.org/configuration/output/#outputhashfunction),
767+
- [output.hashSalt](https://webpack.js.org/configuration/output/#outputhashsalt).
768+
769+
Supported template strings:
770+
771+
- [name] the basename of the resource
772+
- [path] the path of the resource relative to the `compiler.context` option or `modules.localIdentContext` option.
773+
- [file] - filename and path.
774+
- [ext] - extension with leading .
775+
- [contenthash] - the hash of the string, generated based on `hashPrefix`, `localIdentContext`, `resourcePath` and `exportName`
776+
- [local] - original class.
761777

762778
Recommendations:
763779

764-
- use `'[path][name]__[local]'` for development
765-
- use `'[hash:base64]'` for production
780+
- use `'[file]__[local]'` for development
781+
- use `'[contenthash]'` for production
766782

767783
The `[local]` placeholder contains original class.
768784

@@ -779,7 +795,7 @@ module.exports = {
779795
loader: "css-loader",
780796
options: {
781797
modules: {
782-
localIdentName: "[path][name]__[local]--[hash:base64:5]",
798+
localIdentName: "[path][name]__[local]--[contenthash]",
783799
},
784800
},
785801
},

package-lock.json

Lines changed: 56 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
},
4444
"dependencies": {
4545
"icss-utils": "^5.1.0",
46-
"loader-utils": "^2.0.0",
4746
"postcss": "^8.2.10",
4847
"postcss-modules-extract-imports": "^3.0.0",
4948
"postcss-modules-local-by-default": "^4.0.0",

0 commit comments

Comments
 (0)