forked from spryker-shop/suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalias.js
24 lines (20 loc) · 773 Bytes
/
alias.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { join } = require('path');
// get the aliases from the tsconfig.json file
// and transform them in webpack alises
// allowing the definition of aliases in one place
const getAliasList = appSettings => {
const tsConfigFile = join(appSettings.context, appSettings.paths.tsConfig);
const tsConfig = require(tsConfigFile);
const aliases = tsConfig.compilerOptions.paths;
return Object.keys(aliases).reduce((map, name) => {
if (name !== '*' && aliases[name].length) {
const alias = name.replace(/(\/\*?)$/, '');
const aliasPath = aliases[name][0].replace(/(\/\*?)$/, '');
map[alias] = join(appSettings.context, aliasPath);
}
return map;
}, {});
};
module.exports = {
getAliasList
};