GithubHelp home page GithubHelp logo

gulp-rev-css-url's Introduction

gulp-rev-css-url

A lightweight plugin for gulp-rev to replace CSS url() calls with hashed URLs.

This is a fork of @galkinrost's gulp-rev-css-url, which appears to be unmaintained. Changes include:

  • Tested against up-to-date dependencies and Node 18+.
  • Removed support for JS files.
  • Support for relative URLs. e.g. ../images/foo.png
  • Support for query strings and fragments. e.g. myfont-webfont.eot?#iefix

As far as I'm aware, this is the only gulp-rev (or equivalent) plugin that properly handles relative URLs. Most will work, if at all, only if the relative URL backs out to the base directory. (Please let me know if this isn't the case! I'd love other options.)

Sample

Take the following simple CSS file (css/main.css) which references images/dummy.jpg.

body {
	background: url("../images/dummy.jpg");
}

After running gulp-rev with gulp-rev-css-url, the resulting CSS file might look like this:

body {
	background: url("../images/dummy-0849cad9cc.jpg
}

Install

npm install --save-dev @luhn/gulp-rev-css-url

Usage

Add gulp-rev-css-url to your Gulp pipeline, directly after gulp-rev.

const gulp = require('gulp');
const rev = require('gulp-rev');
const override = require('gulp-rev-css-url');

function rev() {
	return gulp.src('./app/**/*')
		.pipe(rev())
		.pipe(override())
		.pipe(gulp.dest('./build/'))
		.pipe(rev.manifest())
		.pipe(gulp.dest('./build/'));
};

exports.default = rev;

gulp-rev-css-url's People

Contributors

battaglr avatar cl0sey avatar coolov avatar cr0ck avatar galkinrost avatar luhn avatar neb avatar tristil avatar

Watchers

 avatar  avatar  avatar

Forkers

thecotne mgu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.