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

gulp-cram

v0.2.0

Published

Assemble resources using cujoJS cram

Downloads

12

Readme

gulp-cram Build Status

Assemble resources using cujoJS cram

Install

Install with npm

npm install --save-dev gulp-cram

Example

Tell cram.js to inspect the main page of an app that uses a static index.html file:

var gulp = require('gulp');
var cram = require('gulp-cram');
var uglify = require('gulp-uglify');

gulp.task('default', function () {

    var opts = {
        configFiles: [ 'build-options.json']
    };

    cram('./client/index.html', opts).into('main.js')
        .pipe(uglify())
        .pipe(gulp.dest('dist'));

});

Instruct cram.js to inspect the run.js file (the AMD configuration file) of a web app that does not use a static html file:

var gulp = require('gulp');
var cram = require('gulp-cram');
var uglify = require('gulp-uglify');

gulp.task('default', function () {

    var opts = {
        appRoot: 'mywebapp/',
        configFiles: [ 'build-options.json' ],
    };

    cram('mywebapp/run.js', opts).into('main.js')
        .pipe(uglify())
        .pipe(gulp.dest('dist'));
});

Explicitly direct cram.js to create a bundle using options from a JSON file:

var gulp = require('gulp');
var cram = require('gulp-cram');
var uglify = require('gulp-uglify');

gulp.task('default', function () {

    var opts = {
        configFiles: [ 'build-options.json' ],
        includes: [ 'mywebapp/curl/src/curl.js' ]
    };

    cram('', opts).into('mywebapp/app.js')
        .pipe(uglify())
        .pipe(gulp.dest('dist'));
});

API

cram(grokfile, options).into(output, readOptions)

grokfile

Type: String

Accepts a a string indicating an HTML or JavaScript file to auto-configure. It uses the same code inference algorithm as cram's command line HTML auto-configuration feature.

options

Type: Object

A JavaScript object like:

var options = {

    // A string representing the path of the root of the application files.
    // This would typically point at the same directory as baseUrl in your AMD config.
    // This option is unnecessary if you specify a grok parameter that references an HTML file.
    appRoot: './src/app/',

    // An array of JSON-formatted files containing AMD configurations.
    // These configuration options will override any found by the grok option.
    configFiles: [ 'cramOverrides.json', 'productionOverrides.json' ],

    // An array of the ids of modules to include in the bundle.
    includes: [ 'analytics/flurry' ],

    // An array of the ids of modules to exclude from the bundle.
    excludes: [ 'app/settings' ],

    // A string indicating the location of an AMD loader script.
    // This script will be inserted at the very beginning of the output bundle.
    loader: './src/lib/curl/loader.js'
};

For more details, check out cram's CLI options.

output

Type: String

Accepts a string indicating path and name of the file to be streamed.

readOptions

Type: Object

A JavaScript object like:

var options = {

    // A boolean that indicates if the result should be a buffer or a stream
    // Default value is 'true', so a buffer
    buffer: true
}

License

MIT © Brian Clozel