0.5.2 • Published 6 years ago

gulp-ts-paths v0.5.2

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 years ago

gulp-ts-paths

Gulp stream to resolve imports aliases defined in 'tsconfig.paths' to relative paths.

Install

npm install --save-dev gulp-ts-paths

Usage

let paths = require("gulp-ts-paths").default;

let config = { ... };

gulp.task("build", function () {
	let tsProject = ts.createProject(config.tsconfig);

	return gulp.src(config.tsGlob)
		// Assuming your ts config directory is "./src"
		.pipe(paths({ config: tsProject.config, baseDir: "./src" }))
		.pipe(tsProject())
		;
});

Example

Given your tsconfig paths is: { "MyAlias": ["MyAliasFolder/MyAliasClass"] }
And a file, relative to tsconfig, is at: ./FileFolder/InnerFileFolder/File.ts

Input:

import A from "./asdf";
import B from "express";
import C from "MyAlias"; // This is the defined alias we want to replace to relative path.

export class MyClass {
}

Output:

import A from "./asdf";
import B from "express";
import C from "../../MyAliasFolder/MyAliasClass";

export class MyClass {
}
0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago