Miss any of our Open RFC calls?Watch the recordings here! »

gulp-flatten-requires

1.0.0 • Public • Published

gulp-flatten-requires build status

Rewrites relative require() calls to use flat paths in the same directory.

Whatever quote type was used in the original require() call will be preserved.

Before After
require('./path/to/a') require('./a')
require('../path/to/b') require('./b')
require("./c") require("./c")

Install

npm install --save-dev gulp-flatten-requires

Usage

This plugin is intended to be used in conjunction with gulp-flatten for a quick-and-dirty means of creating a flat directory of a library's modules to be published to npm for cleaner requiring of the library's constituent parts.

var gulp = require('gulp')
var flatten = require('gulp-flatten')
var flattenRequires = require('gulp-flatten-requires')
 
gulp.task('copy-npm', function() {
  return gulp.src('./build/modules/**/*.js')
    .pipe(flatten())
    .pipe(flattenRequires())
    .pipe(gulp.dest('./npm'))
})

Note: This assumes that every module in your project is uniquely named.

MIT Licensed

Install

npm i gulp-flatten-requires

DownloadsWeekly Downloads

25

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar