Skip to content

Instantly share code, notes, and snippets.

@EZaykov
Created May 13, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EZaykov/9055d4407219648453568f8d18124e83 to your computer and use it in GitHub Desktop.
Save EZaykov/9055d4407219648453568f8d18124e83 to your computer and use it in GitHub Desktop.
npm tsconfig-paths (simple "src" to "dist" replacer)
const tsConfig = require("./tsconfig.json");
const tsConfigPaths = require("tsconfig-paths");
function formatPaths(){
const newPaths = {};
for (const [ key, paths ] of Object.entries(tsConfig.compilerOptions.paths))
newPaths[key] = paths.map(path => path.replace('src', 'dist'));
return newPaths;
}
tsConfigPaths.register({
baseUrl: tsConfig.compilerOptions.baseUrl,
paths: formatPaths()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment