0.0.1-c • Published 6 years ago

gulp-typescript-path-resolver v0.0.1-c

Weekly downloads
32
License
MIT
Repository
-
Last release
6 years ago

gulp-typescript-path-resolver

This is a simple module to replace the typescript path with original path

example

const gulp = require('gulp');
const ts = require('gulp-typescript');
const ts_import = require('gulp-typescript-path-resolver');

const tsProject = ts.createProject('./tsconfig.json');

gulp.task('build', () => {
    return tsProject.src()
        .pipe(tsProject())
        .pipe(ts_import.tsPathResolver(tsProjectSource.config.compilerOptions, {
            // You can Overwrite the path
            "paths": {
                "@app/env": [
                    "environments/environment"
                ]
            }
        }))
        .pipe(gulp.dest(tsProject.config.compilerOptions.outDir))
});

your tsconfig.json

{
  "compilerOptions": {
  "outDir": "./dest"
  , "rootDir": "./src"
  , "noImplicitAny": false
  , "baseUrl": "./src"
  , "module": "commonjs"
  , "paths": {
      "@app/env": [
        "environments/environment"
      ]
      , "@modules/*": [
        "modules/*"
      ]
      , "@util/*": [
        "modules/util/*"
      ]
    }
  }
}

Note: Don't forget to add rootDir option