Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
gulp-tree-concat
Advanced tools
Gulp processor to merge multiple javascript files into one with hierarchy
A Gulp processor to merge multiple javascript files into one with hierarchy
Install using npm.
$ npm install gulp-tree-concat
var jade = require('gulp-jade')
, treeConcat = require('gulp-tree-concat')
gulp.task('template', function () {
gulp.src('client/templates/**/*.jade')
.pipe(jade({client:true, compileDebug: false}}))
.pipe(treeConcat({
output: 'template.js',
namespace: 'Views.JadeTemplates',
hierarchy: true,
nameTemplate: treeConcat.nameTemplates.relative('client/templates/')
})
.pipe(gulp.dest('public/assets'));
});
This compiles all of your jade template into a single file template.js
as precompiled template,
defining Views.JadeTemplates = { /* template fns */ }
.
Let's say we have views located at
client/app/views/item.jade
client/app/views/admin/user.jade
Given the example's option as described before, those views will now be accessible as precompiled jade precompiled client template functions via
Views.JadeTemplates.item
Views.JadeTemplates.admin.user
(Please note that gulp-tree-concat
only take cares to concat the compiled template, the jade template compiling is done by gulp-jade
. And gulp-tree-concat
doesn't have to be used in conjunction with gulp-jade
. Any javascript files will do.)
Type String
The output file name
Type String
, default to this.Templates
The object that holds the concated templates
gulp-tree-concat
respects your namespace, it appends new members to the namespace one by one instead of override the whole object with=
. So multiple output file can be loaded without conflict.
Type Boolean
, default to false
Indicate whether the hierarchy should be built. If
hierarchy
is set tofalse
in the sample, the templateclient/app/views/admin/user.jade
will be stored asViews.JadeTemplates['admin/user']
.
Type String
, default to /
The name divider to parse the hierarchy from the name of the template. Could change to
.
to build hierarchy from filename. Since the value is used inRegExp
, please escape it when necessary. Will be ignored ifhierarchy
is set tofalse
Type function(File)
, (File) -> node name
Mapping, default to treeConcat.path.none
The function to build the name for a file, usually the name is exctract from file name. But also could be extract from
contents
if necessary
Several predefined builder are included:
treeConcat.nameTemplates.fullpath()
Extract the file full path as template name
/folder/file.js
will be mapped to/folder/file.js
treeConcat.nameTemplates.filename(removeExtension = true)
Extract the file name as template name, extension name can be removed
/folder/file.js
will be mapped tofile
Parameters
treeConcat.nameTemplates.relative(baseFolder, removeExtension = true)
Extract the the relative path based on
basedFolder
, extension name can be removed/folder/subfolder/file.js
will be mapped tosubfolder/file
Parameters
baseFolder the relative path that you want to remove from name
removeExtension controls how the extension is removed
MIT
FAQs
Gulp processor to merge multiple javascript files into one with hierarchy
We found that gulp-tree-concat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.