jamesknelson / gulp-rev-replace

Rewrite occurences of filenames which have been renamed by gulp-rev
MIT License
388 stars 62 forks source link

Expose file to `modifyReved`/`modifyUnreved` #40

Open crzidea opened 9 years ago

crzidea commented 9 years ago

Hi, I am writing a task to support replace relative path. Below is my code snippet:

gulp.task('html', ['revision'], function () {
    var manifest = gulp.src('.tmp/rev-manifest.json');

    var srcPath = path.join(__dirname, 'app');
    var revReplaceOptions = {};
    revReplaceOptions.manifest = manifest;
    function modifyDistPath(distPath, file) {
        var fileRelativePath = path.relative(srcPath, file.path);
        var fileDirname = path.dirname(fileRelativePath);
        var distPathRelativePath = path.relative(fileDirname, distPath);
        if (/^../.test(distPathRelativePath)) {
            return distPathRelativePath
        }
        return distPath;
    }
    revReplaceOptions.modifyUnreved = modifyDistPath;
    revReplaceOptions.modifyReved = modifyDistPath;

    return gulp.src('app/**/*.html')
        .pipe($.revReplace(revReplaceOptions))
        .pipe(gulp.dest('dist'));
});

So I need the file.path as an argument to support the feature. The PR is to support this.

jamesknelson commented 9 years ago

Thanks @crzidea. If you could update test.js to test for the new argument, I'd be happy to merge.

crzidea commented 9 years ago

I will update test. And should I update README about this feature?

jamesknelson commented 9 years ago

Yep, updating README would be great too, thanks.

ankon commented 8 years ago

I'm also having issues with relative paths and the rev-replace plugin, if this could be merged it would help me a lot. Can I help moving this forward?

crzidea commented 8 years ago

@ankon Yes, please! I will be grateful if you can take over this!