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-asset-manifest-symfony

v0.0.6

Published

gulp plugin for adding generated assets to a manifest file

Downloads

4

Readme

gulp-asset-manifest

gulp plugin for adding generated assets to a manifest file

We needed to make hashed asset filenames available in a common format that a webserver (Django) could load into the templates. This plugin can easily be modified to suit your own purposes.

It works great with gulp-rev by Sindre Sorhus. gulp-rev adds hashes to the filename, gulp-asset-manifest adds the hashed filenames to the manifest.

How it works

The plugin takes generated or processed asset files (CSS, JS, whatever) and adds them to a JSON manifest file. It separates the files by bundles, so you can have one for CSS, one for JS and your other needs. These bundles can then be read from the manifest file into your templates.

Install

Install with npm:

npm install gulp-asset-manifest --save

See examples below on how to add it to your gulpfile.

Examples

Simple usage

var gulp = require('gulp');
var assetManifest = require('gulp-asset-manifest');

gulp.task('default', function () {
	gulp.src('src/*.js')
		.pipe(assetManifest({bundleName: 'app_scripts'}))
		.pipe(gulp.dest('dist'));
});

Default usage (with gulp-rev)

The use of gulp-rev is completely optional, but recommended for cache-busting etc.

var gulp = require('gulp');
var assetManifest = require('gulp-asset-manifest');
var rev = require('gulp-rev'); // Optional

gulp.task('default', function () {
	gulp.src('src/*.js')
		.pipe(rev()) // Optional
		.pipe(assetManifest({bundleName: 'app_scripts', log: true}))
		.pipe(gulp.dest('dist'));
});

Usage with multiple bundles

To have multiple bundles in the same manifest, add different bundleName parameters to the tasks.

var gulp = require('gulp');
var assetManifest = require('gulp-asset-manifest');

gulp.task('scripts', function () {
	gulp.src('src/*.js')
		.pipe(uglify())
		.pipe(assetManifest({bundleName: 'app_scripts'}))
		.pipe(gulp.dest('dist'));
});

gulp.task('styles', function () {
	gulp.src('src/scss/app.scss')
		.pipe(sass())
		.pipe(assetManifest({bundleName: 'app_styles'}))
		.pipe(gulp.dest('dist'));
});

Usage with Django

We haven't gotten around to open sourcing our implementation of the Django manifest loader.

But @Xowap has created his own version which can be found here: https://gist.github.com/Xowap/f01dad68418dbb8ab110

API

assetManifest(options)

options.bundleName

Type: String Required: Yes

Name of the bundle for this task. E.g. if the tasks handles JS libraries, the bundle name could be 'js_libs'. If the gulp task processes all Sass files, it could be 'main_css'.

options.manifestFile

Type: String Default: asset_manifest.json Required: No

Path of the manifest file which plugin reads from and writes to.

options.pathPrepend

Type: String Default: None Required: No

Prepend a path to the filename. Eg. 'assets/build/'.

options.includeRelativePath

Type: Boolean Default: false Required: No

Will include the relative path of the file(s).

options.pathSeparator

Type: String Default: The default path separator for the current environment Required: No

Override the environment's default path separator. Can be used to convert MSDOS paths (\) to *nix paths ('/').

options.log

Type: Boolean Default: false Required: No

If true, the plugin will output filenames to the console.

License

MIT © Vanja Cosic