1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const {cloneDeep, merge} = require('lodash')
|
11 |
|
12 | function stripDotSlashPrefix(path) {
|
13 | return path.replace(/^\.\//, '')
|
14 | }
|
15 |
|
16 | module.exports = function(entry, opts) {
|
17 | let clone = cloneDeep(opts)
|
18 | const stripedEntry = stripDotSlashPrefix(entry)
|
19 | if (clone.overridesByEntry) {
|
20 | Object.keys(clone.overridesByEntry).forEach((key) => {
|
21 | const stripedKey = stripDotSlashPrefix(key)
|
22 | if (stripedKey !== key) {
|
23 | clone.overridesByEntry[stripedKey] = clone.overridesByEntry[key]
|
24 | }
|
25 | })
|
26 | if (clone.overridesByEntry[stripedEntry]) {
|
27 | clone = merge(clone, clone.overridesByEntry[stripedEntry])
|
28 | }
|
29 | delete clone.overridesByEntry
|
30 | }
|
31 | return clone
|
32 | }
|