Giter VIP home page Giter VIP logo

gulp-rev-all's People

Contributors

achrome avatar aro1976 avatar austinhallock avatar bcbcb avatar builtbylane avatar calvinf avatar circlingthesun avatar demurgos avatar dependabot[bot] avatar englercj avatar fbuecklers avatar frank3k avatar jordaaash avatar magnusvk avatar marshall007 avatar nathankot avatar pioug avatar qixotic avatar saibayadon avatar santiagoaguiar avatar silvenon avatar stefanaxelsson avatar tadeuszwojcik avatar taybin avatar timelf123 avatar wbinnssmith avatar wbprice avatar woodhull avatar wvanderdeijl avatar xpepermint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-rev-all's Issues

Write relative paths to log

Would be nice to have relative paths written to log, so instead of:

[15:33:34] gulp-rev-all: Skipping binary file [ /home/travis/build/koistya/tarkus.me/build/favicon.ico ]

there will be:

[15:33:34] gulp-rev-all: Skipping binary file [ favicon.ico ]

or, even better:

[15:33:34] gulp-rev-all: Skipping binary file: favicon.ico

..where filename is of different color, for example:

gutil.log('gulp-rev-all: Skipping binary file: ' + gutil.colors.magenta(filename));

Support for CSS url() and '@2x' images

The following regex in tools.js adds support for:

  • Urls in CSS delimited by url() (no quotes)

  • File names which contain '@' (pretty common with '@2x' retina images)

    var filepathRegex = /.*?(?:\'|\"|\()([a-z0-9_@\-\/\.]+?\.[a-z]{2,4})(?:(?:\?|\#)[^'")]*?|)(?:\'|\"|\)).*?/ig;
    

RequireJS, and r.js multi-bundle edge case with Gulp-Rev-All

First off thanks for making Rev-All its working really well for me so far all things considered. I am still kinda lost how everyone is supposed be able to quickly just start using Gulp-Rev and the given manifest files like its nothing with so few docs or examples. How is a new person to the JS and Gulp ecosystem supposed to be able to reinvent this level cache busting with only manifest files a time efficient manner their first time. I under stand making your own Gulpy solutions and they are great but Rev-All is doing things right, and at least getting us 99.9% of the way there out of the box. Loving it.

I'm here to report the edge case issue I had with RequireJS bundling and hashing, ideally it can get fixed but it feels a little unique despite it being something it feels like everyone should be doing, namely hashing everything completely.

Basically you bundle you RequireJS AMD modules with the R.JS optimizer and you end up with a common bundle and then optionally you break off packages of code to lazy load in later for pages or features that users won't see right away to reduce page size, sounds great and it is until you want to long cache everything with the help of rev hashing. RequireJS wants you to list all of those lazy loaded bundles without the .js extension internally because it knows how to read it, but that basically makes Rev-All miss the reference link and because of that hashed.js bundle file isn't loaded. All that really matters is the "name of the bundle", the "about":[, the other parts stay the same.Missing Hash Example Image if you add the hash to the internal reference to the bundle (still without the .js) it works great. Bundle Names are now hashed and they work great!

I've already hacked out a really simple solution to patch it that that runs after the Rev-All task and adds the hash references into the common bundle as seen in the second picture, so I wanted to share that Gist (loaded with comments to try and explain it in case others need it too, it took too much effort for how easy it should have been). _RequireJS, and r.js multi-bundle edge case with Gulp-Rev-All Gist patch code_

It works but I'd love to see if anyone can show me how to make it more robust. I would have submitted a pull request but frankly I'm still too new to JavaScript and gulp etc to understand the Rev-All source well enough to add to it well effectively. Maybe you can work out the issue from my Gist and make a real solution.

One thing I did notice trying to work through the Rev-All source,

in Tool.js line 61: "return crypto.createHash('md5').update(str, 'utf8').digest('hex');"

Why are we adding the effect hex digest? It makes the resulting hash different from what the normal Gulp-Rev hash outputs. I only bring it up because my original plan was to use a Rev-Manifest.json like they suggest to do it all by hand, but then I noticed the difference in hashes, odd, and changed plans to just patch on top of the Rev-All output because it is already 99% working out of the box.

Side note though, why can't we have a Rev-All manifest file?

_I think it would be useful to have a .json file that is basically a tree of your build structure with hashes recorded for archiving alongside the locked in artifact version number of a release in git for example_. Say I wanted to support multiple builds in production (maybe mobile apps on many phones over time etc) it would be useful to have a Rev-All-Manifest.json with all the hash values for each version and files that are tagged as a public release in Git, then any errors or bug reports that came in about file "X-{hash}.js" could be referenced using the manifest file hash to help narrow things down while debugging rather then the hash being a hindrance adding to the complexity of the bug. Just a suggestion, or if that is possible already I'd like to hear about how to do that with Rev-All easily.

Anyway look at the Gist for details, lot of comments and pictures. Let me know what you think.
_RequireJS, and r.js multi-bundle edge case with Gulp-Rev-All Gist patch code_

The RegEx is used was built and tested with RegExr.com, great site. This is a small example of a jsonString from the Gist that would represent the .js files in your build dir after using Rev-All, and you'd match it with

/\"\.\/[a-z]*\/(([^\"\/.]*).[a-z0-9.]*)\.js\"/ig
["./build/about.4633414d.js","./build/about.4633414d.js","./build/charts.fb997bcb.js","./build/etc.fb997bcb.js","./build/scripts.ee82b2ec.js"]

image changed but hash not changed

In my create.less file ,it has background: url("/static/images/account/reg-login-bg.png");,then I changed the pic but the name keep the same, then run the task ,but the "constants.5e71645a.less"also keep the same. Can anyone help me ?
gulp file in the below

gulp.task('teststyle',function(){
  var src = [
    'web/static/less/account/create.less'
  ];
  gulp.src(src)
      .pipe(gulp.dest('web/static/compiled/testStyle'))
      .pipe(revall())
      .pipe(gulp.dest('web/static/compiled/revall'))
      .pipe(rev.manifest())
      .pipe(gulp.dest('web/static/compiled/revall'))
  ;
});

Skip favicon.ico since it can never be renamed

Even though I excluded favicon.ico from the files sent to gulp-rev-all the reference to it was still replaced with the md5 version inside of index.html. Filtering from the results before replacement fixed this problem.

Video with 2x file name

A video source with @2x in the filename is missing the revisioning. Version 0.7.2.

No biggie, I can remove the @2x in the filenames, but it's a nice reminder that it's saved at 2x resolution.

Before:

<video id="intro-video" class="intro-video" loop autoplay controls poster="/images/png/[email protected]">
    <source src="video/[email protected]" type="video/mp4">
    <source src="video/[email protected]" type="video/webm">
    <img src="images/png/[email protected]">
</video>

After:

<video id="intro-video" class="intro-video" loop autoplay controls poster="/images/png/[email protected]">
    <source src="video/[email protected]" type="video/mp4">
    <source src="video/[email protected]" type="video/webm">
    <img src="images/png/[email protected]">
</video>

Support for @2x images

image.png and [email protected] should be given the same hash, with the @2x at the end.
Like this:
image.abcdef.png and [email protected]
The hash could be a combination of the hashes of both original images to keep cache busting.
I guess 3x should be supported too :)

the example code is not working

var gulp = require('gulp');
var revall = require('gulp-rev-all');

gulp.task('default', function () {
    gulp.src(['src/**/*.jpg', 'src/**/*.png', 'src/**/*.htm', 'src/**/*.js', 'src/**/*.css'])
        .pipe(revall())
        .pipe(gulp.dest('build'));
});

the html is not referering correct file path:

we can see in the html
but we can also see css.b82bc0c3.css in the same folder, instead of expected css.db955e5d.css.
The js filename is correct....

Output both versionFile and manifest

Hello,

When I do:

stream
      .pipe(revall.manifest({ fileName: 'manifest.json' }))
      .pipe(gulp.dest(DIST_DIR))
      .pipe(revall.versionFile({ fileName: 'version.json' }))
      .pipe(gulp.dest(DIST_DIR));

I'm getting only the manifest. It would be nice to be able to output both!

Also, when I do:

stream
      .pipe(revall.manifest({ fileName: 'manifest.json' }))
      .pipe(revall.versionFile({ fileName: 'version.json' }))
      .pipe(gulp.dest(DIST_DIR));

Nothing gets output

Thanks!

rev-all on an img folder not working completely

I have a folder with 9 images (284kb) both jpg and png. When I run rev-all everything appears to run fine but I end up with references to missing files. It seems to only be able to go through 5 images (totaling ~190kb) both jpg and png. It doesn't throw an error. The file names do not contain spaces.

Has anyone experienced this issue at all?

Incorrect replacing when filename matches search token exactly

Given file abc.js which contains

var Abc = function() {
};

Abc.prototype.fnName = function() {
};

output contains abc.[hash].js with the following content

var Abc.[hash].js = function() {
};

Abc.[hash].js.prototype.fnName = function() {
};

Renaming file to abc1.js solves the problem.

Index.html reference not getting updated

My index file did get it's name updated: index.2e6ac32e.html

But the references inside are incorrect.

I see that the references in my css files did get updated correctly.

I see that the references in my js files got updated correctly

I see that the files that are in the revall ignore rule don't get the links/resources updated, I don't want the name changed but I want the references ok :).

OBS: My index.html is not in revall ignore rule.

Duplicate dependencies in package.json

While doing an npm install, two warnings are shown with duplication of q and gulp-util.

$ npm install
npm WARN package.json Dependency 'gulp-util' exists in both dependencies and devDependencies, using 'gulp-util@~2.2.14' from dependencies
npm WARN package.json Dependency 'q' exists in both dependencies and devDependencies, using 'q@^1.2.0' from dependencies

Removing them from devDependencies and submitting a new PR for it.

Reflect changes in source maps

I love how gulp-rev-all does a terrific job of setting up cache-busting for my app. I also love source maps. Unfortunately, when gulp-rev-all changes my app.css, the corresponding app.css.map no longer matches the contents of app.css.

It would be nice if gulp-rev-all understood source maps, detecting when a file has a //# sourceMappingURL=app.js.map or /*# sourceMappingURL=app.css.map */ and then update the corresponding app.js.map or app.css.map appropriately.

Remove duplicate files

I have separate gulp tasks and the final task is revving the files in my final build folder. I'm ignoring files with the .html extension from being renamed and the references are still hashed which is great. But the problem is that I get both my original files and the hashed files in my final build folder.

For example:

/buildFolder
  /assets
    /css
      styles.css
      styles.abc123.css
index.html

Is there support for removing the original file after it's hashed and just saving the hashed file?

Src exclusions do not work

With this gulp task of mine:

gulp.task('versionize', ['clean:dist', 'build'], function() {
    return gulp.src([
            'build/**',
            '!build/json'
        ])
        .pipe(plugins.revAll({ignore: ['.html']}))
        .pipe(gulp.dest('dist'))
})

The build/json folder still gets copied over. I do not want the json folder in the destination at all. Do you think you have a test case for this? Probably a bug? Thanks!

Generate Manifest File

Up-voting the need for a manifest file. I'd love to switch to this from gulp-rev, but I can't without one. I've been using gulp-rev for a rails project (we're replacing the asset pipeline with gulp tasks), and we have a helper reading the rev-manifest.json that we can use to output correctly hashed filenames in our views.

%link{:href => asset_path('application.css'), :rel => 'stylesheet'}

asset_path checks the manifest data and replaces application.css with application-a6a5d4c2.css. Basically, the same thing that's outlined here: https://github.com/sindresorhus/gulp-rev/blob/master/integration.md

Thanks for your work on this! I love love love that this takes child assets into consideration when generating the hash.

silent option?

Any way to disable console output (e.g. revall({ silent: true }))?

no working fine when there are mutil "requirejs.config" in same file

my requirejs config file like follow:

/**
 * require全局配置项
 */
requirejs.config({
    baseUrl: "./",
    paths: {
        react: "lib/react",
        jquery: "lib/jquery",
        backbone: "lib/backbone",
        underscore: "lib/underscore"
    },
    shim: {
        jquery : {
            exports: "$"
        },
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        underscore: {
            exports: '_'
        },
    },
    map: {
        "*": {
            css: "lib/css"
        }
    }
});

//for routers
requirejs.config({
    paths: {
        "home/index" : "scripts/module/home/index",
        "group/index" : "scripts/module/group/index"
    }
});

and when i run rev-all for this file
it match the last requirejs.config, so result is:

requirejs.config({
    baseUrl: "./",
    paths: {
        react: "lib/react",    //no change  due to no match
        jquery: "lib/jquery",  //no change  due to no match
        backbone: "lib/backbone",  //no change  due to no match
        underscore: "lib/underscore"   no change  due to no match
    },
    shim: {
        jquery : {
            exports: "$"
        },
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        underscore: {
            exports: '_'
        },
    },
    map: {
        "*": {
            css: "lib/css"
        }
    }
});

//for routers
requirejs.config({
    paths: {
        "home/index" : "scripts/module/home/index.hash",  //this change
        "group/index" : "scripts/module/group/index.hash"  //this change
    }
});

and i fixed it with change tools.js line 18

...
amdConfigRegex = /requirejs\.config\s*\(\s*{\s*(?:[^](?!paths["']?\s*:))*[\s,"']*paths["']?\s*:\s*{([^}]*)}/g,

now it well done!

and because i fixed the "map" no match issue the same time, so i can't pr to you~ :)

rel link: https://github.com/acelan86/gulp-rev-all/blob/master/tool.js

changing filenames on .html file

I'm running revall for my build dir and it changes filenames... Should this also edit my index.html file with those filenames (css/js)?

gulp-rev-all 0.8 fails if glob is not installed explicitly

Recently updated gulp-rev-all to 0.8.7 from 0.7.6

It failed my deploy task with the following error

Error: Cannot find module 'glob'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/var/www/the-van-and-man/node_modules/gulp-rev-all/tool.js:4:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

However, once I explicitly installed glob, it worked fine. It would seem that glob should be a dependency instead of a devDependency.

Sending a PR to correct this.

Merge manifest instead of overwrite

gulp-rev recently merged some PR's that added support for merging into a manifest file rather than overwriting it completely. This would allow you to rev-all on an entire tmp folder, and use plugins like gulp-changed and gulp-cached to only rev changed files, and only write the changed files to the manifest. There may be a workaround using gulp-remember but I have yet to figure it out.

would this be in scope for gulp-rev-all?

after rev, my js file content was changed and caused syntax error

I used usemin and uglify to generate minified js then use rev-all to add hash to the js file name.
but after rev-all, my js file failed to execute in browser and syntax error was reported.

In chrome console, I got below error:
"Uncaught SyntaxError: Unexpected token )"
actually it is a jquery source file and the end of the file was changed to “function(e){for(var></iframe>”

gulp-rev-all-error

prefix in amdCommonJs working seems no true

i defined seems

define(["js/some"], function () {
});

and gulpfile.js

gulp.src('**')
    .pipe(revall({
         prefix: "http://cdn.com"
    })
    ...

then i get

define(["http://cdn.cn/js/some.hash"], function () {
});

it no work in requirejs, can not found http://cdn.cn/js/some.hash (no add .js due to requirejs)

so, it's a bug or my mistake?

Changes to images don't result in new md5 hash on CSS file name

Can anyone reproduce?

I've basically swapped in gulp-rev-all in place of gulp-rev in this project:

https://github.com/gdi2290/gulp-jade-usemin

However once I run gulp usemin and then save a change to a PNG reference in CSS, then run gulp usemin again, the MD5 hash of my-css-file.123456.css doesn't change.

body {
  background: url('/img/test.png');
}

Perhaps this feature doesn't exist in this package? Not sure, would appreciate help.

I'd imagine that the browser would still cache /img/test.png regardless or not if the CSS file had a new rev/md5 hash, right? Therefore shouldn't we search recursively through these CSS files for changes to images and file paths and rev them as well? Haven't been able to find the spec yet on browser caching standards for image paths in CSS files... but if I recall they get cached regardless of the CSS file being Expires or Never Expires.

Source map reference not updated

Hello @smysnk

I'm having the same issue as in #53 but with the sourcemap reference :

/*# sourceMappingURL=application.css.map */
//# sourceMappingURL=application.js.map

It does not get updated with the renamed map file

HTML Attributes without quotes are ignored when renaming references.

This is related to #4 and #64. In both cases the solution was to "remove the HTML minification step" which solved the issue.

After spending some minutes looking into why, i noticed that gulp-minify-html by default removes "redundant quotes" from attributes. So when gulp-rev-all looks into the file, it ignores quoteless attributes. I think this has to do with the filepathRegex which i believe does not takes this into account.

To fix this one can add the quotes: true parameter to minifyhtml in order to preserve quotes, but i think it might be best to just fix the RegExp.

CommonJS style references are not processed correctly.

The following seems like a bug to me that should be fixed.

var Layout = require('./layout.js');

gets rewrited to

var Layout = require('layout.[hash].js');

where it should be

var Layout = require('./layout.[hash].js');

It could be easily worked around by adding following transformPath

if (source.indexOf('./') === 0) {
  return './' + rev;
} else {
  return rev;
}

Do you consider this to be a bug or a design decision?

Issue with paths on windows

When I use this module on Windows, everything works great, except paths use windows style slashes (backslashes)
for example:

Found root reference [ app/file-picker/test.jpg ] -> [ app\filepicker\test.rev.0ca82d28161aa4a3171fc2ce.jpg ]

Is it related with using path.join? I'd be really grateful if you could fix it :)

requirejs.config "map" no working

when my require config seems:

requirejs.config({
    baseUrl: "./",
    paths: {
        react: "lib/react",
        jquery: "lib/jquery"
    },
    "shim": {
        "jquery" : {
            "exports": "$"
        }
    },
    map: {
        "*": {
            css: "lib/css"
        }
    }
});

"map" in config is no match amdConfigRegex

Skipping binary files

Just tried this out on a folder of images and got gulp-rev-all: Skipping binary file

Any reason why this plugin prevents this, and is there a way to override?

Shared state between tasks

Digging into #26 found the real problem (?).

Seems like there is some shared state between tasks. Consider I have both client and server files to change links in and have the following content in gulpfile.

var revAll = require("gulp-rev-all");
var runSequence = require('run-sequence');

gulp.task('hash:client', function () {
  return gulp.src('/path/to/code/client')
    .pipe(revAll())
    .pipe(gulp.dest('/some/path/for/client/code'));
});

gulp.task('hash:server', function () {
  return gulp.src('/path/to/code/server')
    .pipe(revAll())
    .pipe(gulp.dest('/some/path/for/server/code'));
});

gulp.task('hash', function (callback) {
  runSequence('hash:client', 'hash:server', callback)
});

If I run this I get exactly what is required — links in server code are set to hashed assets.
If task order is changed (server then client) then I got no hashed links in server code.

In my case it's an awesome side-effect actually. But is this really a side effect, a bug, or intended behaviour. I would consider this a bug (though it plays really nicely in my case) as tasks should not have shared state.

bug with base ./

i have "ome/admin/web/default.dev.itgalaxy.company/public_html/public/assets/theme/favicons/favicon-src.png" in json manifest

Bug in filepath Regex

Hi,

just find out that if the CSS file contains a linear gradient definition, the regExp will also catch a lot of wrong references. Example:

       background: linear-gradient(to bottom, rgba(255,255,255,0) 15%,rgba(0,0,0,0.3) 100%);

will identify top,255,to bottom,255 as references.

The same problem is with @media

    @media only screen and (min-width: $break-large) {
        background-color: $color-bg-default;
    }

will identify min-width as a reference.

I'd consider to use https://github.com/reworkcss/rework instead of a regular expression to catch file references.

Thank you for the hard work!

0.7.2, 0.7.3 broken

I haven't been able to narrow down exactly what the issues is, but when I change from version 0.7.1 to 0.7.2 or 0.7.3 I get a ton of output like this:

partials/edit-project-form.html
modal.show
Project.list
notificationFactory.erro
angular.copy
Project.get
ConfirmPopup.open
notificationFactory.succ
epics.push
start.clon
lastIteration.star
lastIteration.endD
Math.roun
lastIteration.endDate.getT

  • lastIteration.startDate.getT
    lastIteration.endD
    start.clon
    moment.min
    iterations.push
    start.toDa
    end.toDa
    iterations.spli
    iterations.inde
    epics.spli

And some of the css appears to be broken after. Sorry I don't have better info / root cause.

changing naming strategy

Hello,
because of an odd issue me and @odino faced the case of publishing corrupted revved images.
Uploading the fixed (and revved) images on our CDN didn't directly fix the issue since the source images' MD5 was actually the same, therefore the produced revved images' name were all identical to the corrupted ones. Easy to figure out: cached images were not re-downloaded.

Due to this I'm now wondering if it might be good to add an optional callback for the revved file naming strategy. Something like the current transform options would work great and allow for more control.

What do you guys thing about it?

Incorrect (?) piping

Hi,
I see in examples on home page that task is not returning stream (gulp.src('dist/**') and not return gulp.src('dist/**')) thus Gulp does not know when task is finished. And if there are any tasks depending on gulp-rev-all behavior becomes unpredictable.

Without return I have the following log

[16:22:12] Starting 'gulp-rev-all-task'...
[16:22:12] Finished 'gulp-rev-all-task' after 39 ms
[16:22:12] gulp-rev-all: Root directory [ /path/to/assets ]

So gulp reports that task is finished and only then gulp-rev-all starts actual processing.

Adding return to the task leads to the following log

[16:15:02] Starting 'gulp-rev-all-task'...
[16:15:02] gulp-rev-all: Root directory [ /path/to/assets ]
...

and no finished 'hash' in the logs.

Explanation of return vs no return is here
http://stackoverflow.com/questions/21699146/gulp-js-task-return-on-src
and the docs are here
https://github.com/gulpjs/gulp/blob/master/docs/API.md#async-task-support

App cache manifest reference not updated

Hello,

Given the following in the .tmp directory :

app.manifest

CACHE MANIFEST

CACHE:
index.html

NETWORK:
*

index.html

<!DOCTYPE html>
<html manifest="/app.manifest">
</html>

When using the following gulp task :

gulp.task('rev', function() {

  gulp.src('.tmp/**/*')
    .pipe(revall())
    .pipe(gulp.dest('dist/'));

});

The output is :

app.f23887fd.manifest

CACHE MANIFEST

CACHE:
index.cf32c00a.html

NETWORK:
*

index.cf32c00a.html

<!DOCTYPE html>
<html manifest="/app.manifest">
</html>

So the manifest reference is not updated, while the file is processed correctly by gulp-rev-all.
Is this an issue of how I use the plugin ? I don't see anything in the source pointing to the manifest argument being ignored. It's working for all my other files, except this one (even for files in the root directory adjacent to the manifest)

Use path.join instead of 'dir' + '/' + 'dir'

Currently when replacing references in files, you are doing a straight concatenation of files with a '/' to generate the new string. This leads to paths like /index.html being turned into //index.html which no longer work. Changing to path.join fixes this problem.

        // In the case where the referenced file is relative to the base path
        if (rootDir) {
            var fullpath = path.join(rootDir, result[1]);
            if (fs.existsSync(fullpath)) {
                replaceMap[result[1]] = path.join(path.dirname(result[1]), path.basename(revFile(fullpath)));
                gutil.log('gulp-rev-all:', 'Found root reference [', result[1], '] -> [', replaceMap[result[1]], ']');
                continue;
            }
        }

        // In the case where the file referenced is relative to the file being processed
        var fullpath = path.join(path.dirname(file.path), result[1]);
        if (fs.existsSync(fullpath)) {
            replaceMap[result[1]] = path.join(path.dirname(result[1]), path.basename(revFile(fullpath)));
            gutil.log('gulp-rev-all:', 'Found relative reference [', result[1], '] -> [', replaceMap[result[1]], ']');
            continue;
        }

v0.7.0 doesn't work with absolute paths

If you have references like /static/images/logo.png in your scripts this code worked in v0.6.6:

gulp.task('build:rev', function () {
  var files = [
    '/tmp/dist/static/images/**/*.{jpg,png,gif}',
    '/tmp/dist/static/scripts/**/*.js',
    '/tmp/dist/static/styles/**/*.css',
  ];
  return gulp.src(files, {base: '/tmp/dist'})
    .pipe($.revAll())
    .pipe(gulp.dest('/tmp/dist'))
    .pipe($.revAll.manifest({prefix: ''}))
    .pipe(gulp.dest('/tmp/dist'));
});

In v0.7.0 the code tries to replace the absolute path with /tmp/dist/static/scripts/static/images/logo.png which is clearly invalid (bases is an empty array in the md5Dependency function). As the file doesn't exist no reference is updated.

This other way of specifying the base works though:

gulp.task('build:rev', function () {
  var files = [
    '/tmp/dist/static/images/**/*.{jpg,png,gif}',
    '/tmp/dist/static/scripts/**/*.js',
    '/tmp/dist/static/styles/**/*.css',
  ];
  return gulp.src(files, {base: '/tmp/dist'}) // so gulp.dest works
    .pipe($.revAll({base: '/tmp/dist'})) // so gulp-rev-all works
    .pipe(gulp.dest('/tmp/dist'))
    .pipe($.revAll.manifest({prefix: ''}))
    .pipe(gulp.dest('/tmp/dist'));
});

Using the base option causes the manifest to use broken absolute paths

When I use:

    return gulp.src('assets/**')
         // Don't version source map files
        .pipe(revall({ ignore: [ /\.js\.map$/ ]}))
        .pipe(gulp.dest('static/'))
        .pipe(revall.manifest())
        .pipe(gulp.dest('static/'));

I get a correctly made rev-manifest.json with relative filenames as keys.

If I use:

    return gulp.src('assets/js/**', { base: 'assets/' })
         // Don't version source map files
        .pipe(revall({ ignore: [ /\.js\.map$/ ]}))
        .pipe(gulp.dest('static/'))
        .pipe(revall.manifest())
        .pipe(gulp.dest('static/'));

The rev-manifest.json tries to use absolute paths as the file keys (which isn't great). However, it cuts off the beginning of the path, so if my file is located at /home/maurizi/project/assets/js/app.js, what ends up in the rev-manifest.json is "e/maurizi/project/assets/js/app.js": "/static/js/app.js"

Way to handle source maps?

Source maps get renamed separately based on their contents. Is there a way to force them to share the same rev as the file the map?

Hashing References Without Actually Renaming?

With my ignore option set to simply [ '.html' ], references to assets in my HTML, CSS, and JS are updated as expected without renaming the HTML files themselves. Great!

I want to have app.js on the server, but want to point to it with something like below in my HTML. I use rewrite rules to map map the hashed filename back to the real app.js.

<script src="app.3bfe34.js"></script>

Is there a way I can prevent all files from being renamed while still causing references in the source to be hashed?

Cannot use manifest with the default filename

This line:
https://github.com/smysnk/gulp-rev-all/blob/master/index.js#L39
assumes options is an object, but if I don't use a filename i won't pass a "{}" either.

For example this is failing:

gulp.task('build:rev', function () {
  var files = [
    '....files here....',
  ];
  return gulp.src(files})
    .pipe($.revAll())
    .pipe(gulp.dest('dist'))
    .pipe($.revAll.manifest())  // no argument
    .pipe(gulp.dest('dist'));
});

While this is not:

gulp.task('build:rev', function () {
  var files = [
    '....files here....',
  ];
  return gulp.src(files})
    .pipe($.revAll())
    .pipe(gulp.dest('dist'))
    .pipe($.revAll.manifest({}))  // empty object
    .pipe(gulp.dest('dist'));
});

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.