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

@pingy/export

v5.0.7

Published

Compile static site for production (with sourcemaps), auto-compiles files like `app.coffee -> app.js`

Downloads

33

Readme

Baconize

npm version Build Status

Compile/minify static site for production (with sourcemaps), auto-compiles files like app.coffee -> app.js.

Currently supports: LiveScript, babel, coco, coffee-script, dogescript, less, marked, myth, jade, node-sass, stylus, swig. To use any of these you must do npm install x as needed (where x is the name of the lib), baconize does not install them by default.

Example

var baconize = require('baconize');

var source = '/path/to/input/dir';
var target = '/path/to/output/dir';
baconize(source, target, [options]).then([successFn],[errorFn]);

How it works:

  • Baconize will walk your source directory and process each file in /path/to/input/dir:
  • If it can compile a file then it will compile it and output it to the target directory (with source map).
  • If it can't compile the file then it will simply copy it to the target.

For example, if you have a coffeescript file in /path/to/input/dir/my-app/scripts/index.coffee then it will output the compiled file as /path/to/output/dir/my-app/scripts/index.js, and the sourcemap as /path/to/output/dir/my-app/scripts/index.js.map.

This library is designed for use alongside pingy-in-the-middle.

Options

  • compile (Boolean, default = true): should baconize try to compile files where possible?

  • sourcemaps (Boolean, default = true): should baconize copy corresponding sourcemaps and source files for the minified/compiled files?

  • minify (Boolean, default = false): should baconize minify javascript, css and html files? Will also minify post-compilation files.

  • blacklist (Array): filter to blacklist files from being compiled or minifed. They will still be copied (without compilation/minifiction) unless they are negated using the fileFilter or directoryFilter options below. This option is useful for vendor directories (like 'bower_components') which already include the compiled versions of files. See Filters for more.

  • fileFilter (Array): filter to include/exclude files to be copied to target. See Filters for more.

  • directoryFilter (Array): filter to include/exclude directories to be copied to target, rules are applied to sub-directories also. Useful for directories like '.git'. See Filters for more.

  • depth (Number): depth at which to stop recursing even if more subdirectories are found.

  • exclusions (Object): Instead of blacklist, fileFilter and directoryFilter you can use the new exclusions api, this is undocumented for the moment.

Filters

Filters take an array of glob strings. fileFilter and directoryFilter can be a whitelist or blacklist, by default they are whitelist but add the ! character before entries to turn them into a blacklist instead:

  • compileBlacklist: [ 'bower_components/**' ] copies the raw 'bower_components' directory instead of compiling files within the directory.

  • fileFilter: [ '*.json', '*.js', '*.scss', '*.jade' ] includes only JavaScript, JSON, SCSS and Jade files.

  • directoryFilter: [ '!.git', '!node_modules' ] includes all directories except '.git' and 'node_modules'.

See minimatch for some examples of glob strings.

Events

You can listen to chdir and compile-start and compile-finised events emitted by baconize.

var bacon = baconize(source, target, [options]);

bacon.on('chdir', function(folder) {
  // `folder` (string) is the current folder path that is being processed by baconize
});

bacon.on('compile-start', function(file) {
  // compile has started on `file` (object).
  //
  // {
  //    name: 'typography.css',
  //    path: 'styles/typography.css',
  //    fullPath: '/Users/dave/Sites/my-site/styles/typography.css',
  //    parentDir: 'styles',
  //    fullParentDir: '/Users/dave/Sites/my-site/styles/',
  //    stat: {object} See: https://nodejs.org/api/fs.html#fs_class_fs_stats
  // }
});

bacon.on('compile-done', function(file) {
  // compile has finished successfully on `file` (object, see above).
});

Aborting while in progress

You can abort baconize while it's in progress. If you do this then the promise will reject and the output directory will be removed.

var bacon = baconize(source, target, [options]);

// abort baconize while in progress
setTimeout(function() { bacon.abort(); }, 10);

bacon.then(function(){}, function(err) {
  // err (Error)
  // {
  //    message: 'Manually aborted by user',
  //    code: 'ABORT'
  // }
})

Try it out

The easiest way to try this out is to clone the repo, cd into it and do:

npm install
npm run example

This will compile a basic demo site to examples/output.