Gulp plugin to recursively flatten JS files into a single directory
gulp-dot-flatten is a gulp plugin to recursively flatten JS files into a single directory.
Will rewrite the following filenames when used with the usage example below:
/build/Main.js
/build/Foo/Bar.js
/build/Foo/Bar/Baz.js
Into this:
/dist/Main.js
/dist/Foo.Bar.js
/dist/Foo.Bar.Baz.js
Any require('./foo/bar')
will be rewritten into require('./foo.bar')
.
This library is made specifically for usage with Screeps due to its lack of directory support.
npm install --save-dev gulp-dot-flatten
var dotFlatten = require('gulp-dot-flatten');
gulp.task('flatten', () => {
return gulp.src('./build/**/*.js')
.pipe(dotFlatten())
.pipe(gulp.dest('./dist'));
});
Type: Function
Optional function in which the filename will pass through. Useful for things like forcing lowercase filenames, if desired.
Example:
var dotFlatten = require('gulp-dot-flatten');
gulp.task('flatten', () => {
return gulp.src('./build/**/*.js')
.pipe(dotFlatten({
stringFilter: (str) => str.toLowerCase()
}))
.pipe(gulp.dest('./dist'));
});
Type: Boolean
Default: false
gulp-dot-flatten is based on the inline library of the same name found in the Screeps TypeScript Starter Kit.
Original authors and contributors:
gulp-dot-flatten is open-sourced software licensed under the MIT License.