
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
Static site generator generator on top of gulp ecosystem
Berber is a tool for creating your own static site generator cli with the combination of gulp plugins and/or gulp compatible transforms. There are lots of nice gulp plugins and utilities on npm, so most of transformations / transpilations / bundlings of static resources which are necessary for various kind of demands can be done by the existing plugins and modules. You can build your own static site generator for your specific demands with these abundant ecosystem and can automate lots of your build configuration tasks for static site building.
With berber, you can build static site generator with 2 main commands build and serve.Suppose your tool's name is foobar, then your command works as development server when called like foobar serve. It outputs static resources when called like foobar build. What you need to set up with berber is only your build pipelines using berber.asset(paths) method.
const berber = require('berber')
berber.name('my-site-generator')
berber.asset('source/**/*.md').pipe(marked())
The above script works as cli. When called with build command like script.js build, then it outputs static resources to build/ directory. When you want configure the output directory, then call berber.dest(dest) method:
berber.dest('output')
When you want to this output path configurable by the user of your command, then bind to config event on berber object:
const berber = require('berber')
const { asset, dest } = berber
berber.name('my-site-generator')
berber.on('config', config => {
const dest = config.dest || 'build'
dest(dest)
asset(...).pipe(...)
})
Here asset() chains to .pipe method. This .pipe call defines your pipeline for the assets. You can chain arbitrary number of pipes.
const frontMatter = require('gulp-front-matter')
const marked = require('gulp-marked')
const layout1 = require('layout1')
berber.asset('source/**/*.md')
.pipe(frontMatter({ property: 'data' })
.pipe(marked())
.pipe(layout1.nunjucks(path.join(__dirname, 'src/layout.njk'))
The above transforms the markdown files at source/**/*.md by 3 transforms; extracting frontmatters, transforming them to htmls and wrapping them with the nunjucks template src/layout.njk. This is similar to what middleman does to markdown files.
You can even define different kinds of starting points:
berber.asset(paths.markdowns).pipe(...)
berber.asset(paths.css).pipe(...)
berber.asset(paths.js).pipe(...)
The above example transforms markdowns, stylesheets and javascripts with different pipelines for each resource.
Install via npm:
npm i berber
First create your script like below:
const path = require('path')
const berber = require('berber')
berber.on('config', config => {
const source = config.source || 'source'
const dest = config.dest || 'source'
berber.asset(path.join(source, '**/*.md'))
.pipe(marked())
.pipe(yourAwesomeTransform())
berber.dest(dest)
})
berber.name('foobar')
With the above settings, your tool's name is foobar and when the user of this script invokes it, it looks up the config file of the name foobar.yml foobar.json or foobar.js. (If you want to change the name of the config file from your tool's name, then use berber.configName(name) method.)
Then set the above script to bin property in your package.json.
{
...
"bin": {
"foobar": "index.js"
},
...
}
Then publish it to npm and your command works like the below:
./node_modules/.bin/foobar build # => builds your site
./node_modules/.bin/foobar serve # => serves your site with builtin dev server
That's the basics of berber.
You can add the custom action by calling berber.action.
berber.action('post', 'Post the new article', argv => {
doSomething(argv)
})
The above adds the command foobar post (given that your module name is foobar) and when the user of your module hit the command foobar post, then the above doSomething(argv) is called, where argv is the cli options parsed by minimist.
const {
name,
configName,
asset,
on,
dest,
base,
port,
debugPageTitle,
debugPagePath,
loggerTitle,
addMiddleware,
action
} = require('berber')
Sets the name of your command.
Sets the name of your command's config file. Default is the same as the name.
Sets the asset from the given paths. You can build your pipeline by chaining .pipe() call to each asset. The returned value has the same interface as bulbo's asset interface. See bulbo's document for details.
Binds cb to the given event.
Currently available events: config, serve
config eventAt config event, cb is called with given user config object. You can set assets, paths etc according to the user's configuration.
berber.on('config', config => {
berber.asset(`${config.source}/**/*.md`).pipe(marked())
})
In the above example, your command look for ${config.source}/**/*.md as markdown sources, which means your command's user can configure the location where markdown files exist.
serve eventThis event happens when the berber start serving files. The features which only work on serve actions, like livereload, should be set up on this event.
Sets the build destination path.
Sets the default basepath of your assets.
If the basepath is src and one of your assets is src/js/foo/bar.js, then it builds into build/js/foo/bar/js. If you change base to src/js, then it builds into build/foo/bar.js.
Sets the port number of the dev server.
This works for serve command.
Sets the title of the debug page.
This works for serve command.
Sets the path of the debug page.
This works for serve command.
Example:
debugPagePath('__mytool__')
// => This makes the debug page path to be `http://localhost:[port]/__mytool__`
The default of the debug page path is __berber__.
Sets the title of the logger. Default is the same as name of your command.
Adds the connect compliant middleware to the server.
const livereload = require('connect-livereload')
addMiddleware(() => livereload())
Sets the custom action to your command. cb takes the command line options as an object which is parsed by minimist.
serve event.MIT
FAQs
Static site generator generator on top of gulp ecosystem
The npm package berber receives a total of 60 weekly downloads. As such, berber popularity was classified as not popular.
We found that berber 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
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.