Socket
Socket
Sign inDemoInstall

gulp-asset

Package Overview
Dependencies
89
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp-asset

Gulp module for managing asset revisions and using multiple domains to server assets.


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
2.00 MB
Created
Weekly downloads
 

Readme

Source

gulp-asset

Gulp module for managing asset revisions and paths.

  • Define assets in all resources using 'asset://' prefix. These will be replaced with correct paths.
  • Adds revision hash using md5 hash of file contents
  • Load balance assets across domains
  • Use manifest file to access revision files within javascript
  • Assets always loaded from same domain
  • Detects broken asset urls during build process
  • Template engine agnostic

Creates revision using md5 hash of file contents and replaces all occurances of path in referencing files. Also allows you to prefix asset urls for balancing across cdn domains. It will also ensure that a single file only ever comes from the one prefix so assets aren't double downloaded.

Install

Install with npm

npm install --save-dev gulp-asset

Usage

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

asset.config({
	prefix: ['http://cdn1.google.com', 'http://cdn2.google.com']
});

gulp.task('js', function () {
	gulp.src('src/assets/js/**/*.js')
		.pipe(asset.rev())
		.pipe(asset.replace())
		.pipe(gulp.dest('dist/assets/js'));
});

Examples

Example JavaScript file

// You can explicitly use an asset:// string
var image = 'asset://img/image.png';
var font = 'asset://fonts/test.eot';

// Or construct a path and use the window.__assets variable
var key = 'asset://' + 'fonts/' + 'test' + '.eot';
var font = window.__assets[key];

Example HTML file

<img src="asset://img/image.png">

Example CSS file

body {
	background: blue url('asset://img/image.png');
}

License

MIT

Keywords

FAQs

Last updated on 27 May 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc