npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

assets-builder

v0.1.6

Published

Assets builder. Build modern assets, JS, CSS, SVGs, transpile ES6 to ES5, CSSNext to CSS3, compress, minify, etc with simple node scripts and CLI.

Readme

Bunny Assets Builder 0.1.6 (Alpha)

Website NPM downloads/month NPM version

Node scripts and custom CLI made easy

Forget about huge Webpack configs and many dependencies. Just run node build all -p to build your production project.

Image: Bunny Assets Builder help example

Image: CSS command example

Why Bunny Assets Builder?

  • Only one dependency instead of many;
  • Just install and it works;
  • Easily extendable and configurable;
  • Many times faster then Gulp or Webpack;
  • No learning curve;
  • Use the flexibility of Node.js scripts instead of Gulp/Webpack;
  • Write own Node CLI;
  • Can be used in Laravel projects replacing laravel elixir.
  • Use ES6/ES7, Future CSS today without installing and configuring a lot of complicated tools!

Assets Builder is an Object-Oriented JavaScript API allowing writing custom Node.js scripts and own CLI easily. To add new cmd just do:

CLI.registerCmd('hello', 'Say hello', [], () => {
  console.log('Hello, world!');
})

and you may use now new command by running node build hello;

By defaults Assets Builder allows building modern web projects out of the box:

  • Transpile ES6 to ES5 using Babel and Rollup;
  • Transpile Future CSS (CSS4) with PostCSS and CSSNext;
  • Compress, minify assets for production by adding -p flag;

Coming soon:

  • Many projects don't have documentation because there are no easy way to add it to existing projects. With Bunny Assets Builder you will be able to generate projects docs from .md files with GitHub syntax highlighting.
  • SVG today is a general practice used in any application. Building SVG sprite is a painful work, soon it will be changed;

Installation

  1. npm install assets-builder --save;
  2. Create file in the project root - build.js;
  3. Import assets-builder, init and run it. You may add custom commands between init() and run().

const CLI = require('assets-builder');

CLI.init();

CLI.run();

Configuration

By default Bunny Assets Builder uses Laravel PHP framework's folder structure and is compatible with manifest/elixir function. It can be used instead of laravel elixir.

module.exports = {

  srcPath: 'resources/assets',
  buildPath: 'public/build',

  srcPathJs: 'resources/assets/js',
  buildPathJs: 'public/build',

  srcPathCss: 'resources/assets/css',
  buildPathCss: 'public/build',

  versionManifestPath: 'public/build/rev-manifest.json',

  allCmds: [
    'css',
    'js',
    'version app.css app.js',
  ],

};

Version Manifest file is a JSON file generated with node build version which can be used by an application to get versioned file path (with random hash added at the end). For example, in Laravel having this rev-manifest.json: {"app.js":"app-quovy03k4.js","app.css":"app-lobywqy2g.css"} calling elixir('app.js') from view would return app-quovy03k4.js.

allCmds is an array of commands which should be executed in defined order using node build all or node build all -p.

Extending and injecting custom Config

  1. Create folder for Node scripts, for example, node_scripts;
  2. Create Config.js
  3. Import original Config, change it and export new one:
const BaseConfig = require('assets-builder/node_scripts/config');

module.exports = Object.assign({}, BaseConfig, {

  srcPath: 'test_scripts',
  buildPath: 'test_scripts/build',

  srcPathJs: 'test_scripts',
  buildPathJs: 'test_scripts/build',

  srcPathCss: 'test_scripts',
  buildPathCss: 'test_scripts/build',

  versionManifestPath: 'test_scripts/build/rev-manifest.json',

});

Now in main build.js replace config:

const CLI = require('assets-builder');
const ProjectConfig = require('./node_scripts/config'); // add this

CLI.Config = ProjectConfig; // add this

CLI.init();

CLI.run();

Usage

Type node build to view the list of available commands.

List of global flags can be used in any command:

  • -p - will execute a command in Production mode, for example, to minify JS and CSS, and to remove comments.

List of default commands:

Image: Bunny Assets Builder help example

If no argument specified JS will use app, CSS will use app and Version will use app.js app.css.

node build css index -p - will, for example, bundle index.css file in the CLI.Config.srcPathCss and save it to CLI.Config.buildPathCss/index.css.

Version command will copy files from Config.CLI.buildPath directory.

Custom commands

To create simple custom command use CLI.registerCmd(name, description, [params in description], callback)

callback will be called with params: (args, isProduction, Config) when command executed in Terminal.

In build.js register new cmd after init() and before run():

const CLI = require('assets-builder');

CLI.init();

CLI.registerCmd('hi', 'My first command', [], (args, isProduction, Config) => {
   console.log('My 1st cmd :)');
});

CLI.run();

Custom "all" command (Sequence of commands)

CLI.registerAllCmd('css-admin', 'Bundle and version admin CSS', [], [
  'css admin',
  'version admin.css'
]);

Custom Node scripts

For more complicated commands it is recommended to write Node scripts and store them in a single directory, for example, node_scripts.

Last argument in CLI.registerCmd() may accept also an object which has run() method which will accept same 3 arguments as callback.

For example, let's create a simple node script:

// node_scripts/hello.js

const colors = require('colors/safe');

const Hello = {
  srcPath: '',
  buildPath: '',
  isProduction: false,

  run(args, isProduction, Config) {
    this.srcPath = Config.srcPathJs;
    this.buildPath = Config.buildPathJs;
    this.isProduction = isProduction;

    const name = args.length === 0 ? 'Mev-Rael' : args[0];

    return this.sayHello(name);
  },

  sayHello(name) {
    console.log(colors.green(`Hello, ${name}`);
  }
};

and register our new script in build.js:

// build.js

const CLI = require('./node_scripts/cli');
const Hello = require('./node_scripts/hello');

CLI.init();

CLI.registerCmd('hello', 'Say hello', ['<name>'], Hello);

CLI.run();

Now node build hello will print Hello, Mev-Rael or node build hello John will print Hello, John.

Node scripts are much more flexible then any Gulp or Webpack plugins. Storing each script in separate file will make your build process maintanable and enjoyable.