Coder Social home page Coder Social logo

gulp-css-urlversion's Introduction

gulp-css-urlversion

Plugin inlines md5-based version of url() resources in css files to force web browsers to fetch updated resources only.

Install

$ npm install --save-dev gulp-css-urlversion

Usage

Example css/sass source:

.royal_button {
    background: url(/images/bg-royal-button.png) 0 0 no-repeat;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

output css:

.royal_button {
    background: url(/images/bg-royal-button.png?v=aa73ac3b951818635c87dc4f56e9cc97) 0 0 no-repeat;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

gulpfile.js:

var gulp = require('gulp'),
    sass = require('gulp-sass'),
    sourcemaps = require('gulp-sourcemaps'),
    cssUrlVersion = require('gulp-css-urlversion');

gulp.task('sass', function () {
    gulp.src('./sass/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass({errLogToConsole: true}))
        .pipe(cssUrlVersion({baseDir: './static/www/'}))
        .pipe(sourcemaps.write('../maps/newthemes/'))
        .pipe(gulp.dest(_csspath + 'css/'));
});

###Options

baseDir - root for root-relative url() resources that you want to version. By default - process.cwd() is used as a root for root-relative resources.

Changelog

####Version 1.1.3

  • ignore https:// urls also

####Version 1.1.2

  • handling closing paranthesis in url()s path to fix #1. Thanks @flftfqwxf :)
  • tests updated

####Version 1.1.1

  • tests added

####Version 1.1.0

  • Support for relative defined url()s
  • Support for multiple background declarations

gulp-css-urlversion's People

Contributors

gothy avatar rainfore avatar

Watchers

 avatar  avatar

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.