gulp-css-ver
Add md5-version-querying-param that based on pictrues files to pictures requirement role 'url()' in your css files.
Last updated 3 years ago by lancercomet .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-css-ver 
SYNC missed versions from official npm registry.

gulp-css-ver

A small gulp tool to add version that based on md5 of pictures to "url()" in css files.

Usage

cssVer(distDirName, secDistDirName, versionName);

distDirName is where the css files will be generated. Gulp-css-ver will try to read all pictrues that are required in css files and root path are based on distDirName firstly. Gulp-css-ver will try to read these picture files in secDistDirName if there are no these required-pictrue in folder distDirName.

Please note that distDirName is relative to rootpath of your project. For example, if your css files is in "PROJECT_DIR/public/index", then you should set distDirName to public/index.

If you provided a versionName, all querying params in url(xxx?@queryingParam) will be replaced with versionName.

Example

var gulp = require("gulp");
var rename = require("gulp-rename");
var stylus = require("gulp-stylus");
var autoprefixer = require("gulp-autoprefixer");
var sourcemap = require("gulp-sourcemaps");
var cssVer = require("gulp-css-ver");

gulp.task("stylus-to-css", function () {
        gulp.src("main-package.styl")
            .pipe(sourcemap.init())
            .pipe(stylus({
                compress: true
            }))
            .pipe(autoprefixer({
                browsers: ['> 1%', 'last 3 versions', 'Firefox ESR', "ie 8", "ie 9"]
            }))
            .pipe(cssVer("public/index", "dist/index"))
            .pipe(rename("bundle.min.css"))
            .pipe(sourcemap.write("."))
            .pipe(gulp.dest("./public/index"));  // dist.
});

Result

Before:

background-image: url("xxx.png")

After:

background-image: url("xxx.png?xxxx")

License

MIT. © 2016 LancerComet.

Current Tags

  • 1.0.9                                ...           latest (3 years ago)

9 Versions

  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           3 years ago
  • 1.0.6                                ...           3 years ago
  • 1.0.5                                ...           3 years ago
  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 9
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |