1 | const { interpolateName, getHashDigest } = require('loader-utils');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | exports.getRoot = function getRoot(tree) {
|
8 | return tree.find(node => typeof node === 'object' && 'tag' in node);
|
9 | };
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | exports.interpolate = function interpolate(pattern, resourcePath, options = null) {
|
20 | const opts = Object.assign({ context: process.cwd() }, options);
|
21 |
|
22 | return interpolateName({ resourcePath }, pattern, opts);
|
23 | };
|
24 |
|
25 | exports.getHash = function getHash(content) {
|
26 | return getHashDigest(content, 'md5', 'hex', 6);
|
27 | };
|