Created
May 13, 2019 18:21
-
-
Save EZaykov/9055d4407219648453568f8d18124e83 to your computer and use it in GitHub Desktop.
npm tsconfig-paths (simple "src" to "dist" replacer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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