Miroslav Jonaš 8ab463e386
cleanup(core): replace deprecated usage of appRootPath (#6241)
* cleanup(core): replace deprecated usage of appRootPath

* cleanup(core): revert migration changes
2021-07-05 15:51:19 -04:00

27 lines
769 B
TypeScript

import * as path from 'path';
import { appRootPath } from '@nrwl/tao/src/utils/app-root';
import { readJsonFile } from '@nrwl/workspace/src/utilities/fileutils';
function onCreateBabelConfig({ actions }, options) {
const tsConfig = readJsonFile(path.join(appRootPath, 'tsconfig.base.json'));
const tsConfigPaths: { [key: string]: Array<string> } =
tsConfig.compilerOptions.paths;
const paths = Object.entries(tsConfigPaths).reduce((result, [key, paths]) => {
return {
...result,
[key]: paths.map((p) => path.join(appRootPath, p)),
};
}, {});
actions.setBabelPlugin({
name: require.resolve(`babel-plugin-module-resolver`),
options: {
root: ['./src'],
alias: paths,
},
});
}
export { onCreateBabelConfig };