gulp-absolute-path

import & require absolute path gulp plugin

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
gulp-absolute-path
1.0.44 years ago5 years agoMinified + gzip package size for gulp-absolute-path in KB

Readme

gulp-absolute-path
import及びrequireのパスをルートディレクトリを基準とした絶対パスで指定できるようにします。

Install

$ npm install --save-dev gulp-absolute-path

Usage

const gulp =    require('gulp');
const abspath = require('gulp-absolute-path');
const ts =      require('gulp-typescript');

gulp.task('build', function ()
{
  const tsOptions = {
    target:  'es6',
    module:  'commonjs',
    jsx:     'react',
    baseUrl: './app'
  };

  return gulp
    .src(['./app/**/*.ts', './app/**/*.tsx'])
    .pipe(abspath({rootDir:'./app'}))
    .pipe(ts(tsOptions))
    .pipe(gulp.dest('./app/'));
});

Example

+ app
|  + controllers
|  |  + api
|  |     + login
|  |        + login.ts
|  |        + valid.ts
|  + utils
|     + utils.ts
|     + slog.js
+ node_modules

Before

login.ts
import express = require('express');
import valid from './valid';
import Utils from '../../../utils/utils';
const slog = require('../../../utils/slog');
const crypto = require('crypto');

After

login.ts
import express = require('express');
import valid from './valid';
import Utils from 'utils/utils';
const slog = require('utils/slog');
const crypto = require('crypto');

Excluded

Node.js standard modules, nodemodules packages, relative path.

Changelog

  • 1.0.4
update packages
  • 1.0.3
ignorePathes add domain, http2, inspector, perf
hooks
  • 1.0.2
nodemodulesパスの判定ミスを修正
  • 1.0.0
Initial release