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 🙏

© 2024 – Pkg Stats / Ryan Hefner

assets-packager

v1.2.0

Published

Very fast assets pipeline - combines power of async, uglify-js, clean-css, enhance-css and couple other tools to make your assets production-ready

Downloads

46

Readme

NPM version Build Status Dependency Status devDependency Status

What is assets-packager?

Assets-packager is a tool for compiling, minifying, and packaging CSS and JavaScript assets into production-ready packages.

CSS bundles are created from assets which are:

  • compiled from LESS templates (optional),
  • minified using clean-css,
  • bundled,
  • preprocessed via enhance-css (inline images, asset hosts, etc),
  • and packaged (and optionally precompressed).

Similarly JavaScript files are:

  • bundled,
  • minified using UglifyJS,
  • and packaged (and optionally precompressed)

Usage

What are the requirements?

node.js 0.8.0+ on *nix (fully tested on OS X 10.6+ and CentOS) and Windows

How to install assets-packager?

npm install -g assets-packager

Tl;dr. Give me a quick demo!

OK. Here are commands to run

git clone [email protected]:jakubpawlowicz/assets-packager.git
cd assets-packager/examples
assetspkg -c assets.yml -g

Now check examples/public/javascripts/bundled and examples/public/stylesheets/bundled for bundled code. That's it!

Is it fast?

You should have just witnessed it by yourself. :-)

It is used as a part of build process for GoalSmashers.com and it takes around 10 seconds to buld 40 CSS and 20 JavaScript bundles from hundreds of assets.

So yes, it is fast!

How to use assets-packager in my application?

First of all it assumes Rails-like directory structure for your assets, e.g:

  • public
    • javascripts
      • some scripts
    • stylesheets
      • some styles

Then it needs a configuration file (here we name it assets.yml) with a definition of JS/CSS bundles, e.g:

stylesheets:
  application: 'reset,grid,base,application'
javascripts:
  application:
    - 'vendor/jquery'
    - 'application,helpers'

We recommend placing it somewhere else than in your public folder.

Now you can bundle all these packages with a single command:

assetspkg -c assets.yml

All the packages go into public/javascripts/bundled and public/stylesheets/bundled.

How to use assets-packager CLI?

Assets-packager accepts the following command line arguments:

assetspkg [options]

-h, --help                  output usage information
-v, --version               output the version number
-b, --cache-boosters        add MD5 hash to file names aka hard cache boosters
-c, --config [path]         path to file with bundles definition (defaults to ./config/assets.yml)
--css-asset-hosts [list]    assets host prefix URLs with in CSS bundles
--css-bundle-to [path]      path to stylesheets root directory (relative to --root option)
--css-embed-all             forces embedding of all resources by enhance-css
--css-safe-embed            create an additional version of packaged CSS without embedded images
--css-source [path]         path to stylesheets root directory (relative to --root option)
-g, --gzip                  gzip packaged files
-j, --concurrent [value]    number of concurrent tasks executed at once (defaults to number of logical CPUs)
--js-bundle-to [path]       path to JavaScript root directory (relative to --root option)
--js-indent [value]         indentation level in spaces when used with --js-no-minify switch
--js-line-break-at [value]  number of characters per line in optimized JavaScript (defaults to no limit)
--js-no-minify              turn off JS minification
--js-source [path]          path to JavaScript root directory (relative to --root option)
-o, --only [list]           package only given assets group or groups if separated by comma(s)
-r, --root [path]           root directory with assets directories (defaults to ./public)

What are the assets-packager's dev commands?

First clone the source, then run:

  • npm run check to check JS sources with JSHint
  • npm test for the test suite

The feature I want is not there!

Open an issue. Or better: fork the project, add the feature (don't forget about tests!) and send a pull request.

Contributors

  • Jean-Denis Vauguet @chikamichi - --nominifyjs and --indent options allow for combination-only processing.

License

Assets-packager is released under the MIT License.