1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | const loaderUtils = require('loader-utils');
|
11 | const path = require('path');
|
12 |
|
13 | module.exports = function getLocalIdent(
|
14 | context,
|
15 | localIdentName,
|
16 | localName,
|
17 | options
|
18 | ) {
|
19 |
|
20 | const fileNameOrFolder = context.resourcePath.match(
|
21 | /index\.module\.(css|scss|sass)$/
|
22 | )
|
23 | ? '[folder]'
|
24 | : '[name]';
|
25 |
|
26 | const hash = loaderUtils.getHashDigest(
|
27 | path.posix.relative(context.rootContext, context.resourcePath) + localName,
|
28 | 'md5',
|
29 | 'base64',
|
30 | 5
|
31 | );
|
32 |
|
33 | const className = loaderUtils.interpolateName(
|
34 | context,
|
35 | fileNameOrFolder + '_' + localName + '__' + hash,
|
36 | options
|
37 | );
|
38 |
|
39 | return className.replace('.module_', '_').replace(/\./g, '_');
|
40 | };
|