shonny-ua / gulp-rev-collector

Static asset revision data collector from manifests, with was generated from different streams and replace they's links in html template.
MIT License
150 stars 41 forks source link

dirReplacements does not work #35

Open fujunchun opened 7 years ago

fujunchun commented 7 years ago

when I use dirReplacements option, it does not work.

shonny-ua commented 7 years ago

Give me , please, more information about this problem.

ireeoome commented 6 years ago

I got the same problem,my rev-manifest.json is like below:

{
  "js/util/util.js": "js/util/util-17b72c16ec.js"
}

and I processd this file with gulp-rev-collector,like this:(I used gulp-load-plugins to load plugins)

gulp.task("rev", function () {
    return gulp.src(`build/rev-manifest.json`)
        .pipe($.revCollector({
            replaceReved: true,
            dirReplacements: {
                'js': function (manifest_value) {
                    console.log(manifest_value)
                    return '//js.40017.cn/touch/hb/c/2/';
                },
            }
        }))
        .pipe(gulp.dest('build/')) // write manifest to build dir
})

but it does nothing, the rev-manifest.json is still what it looked like before, please help me,thank u~

ireeoome commented 6 years ago

I hope the result is :

{
  "js/util/util.js": "//js.40017.cn/touch/hb/c/2//util/util-17b72c16ec.js"
}
shonny-ua commented 6 years ago

Try to use:

dirReplacements: {
                '': function (manifest_value) {
                    return '//js.40017.cn/touch/hb/c/2/' + manifest_value;
                },
            }

Or make manifest file, contains

{
  "util/util.js": "util/util-17b72c16ec.js"
}

and task code:

gulp.task("rev", function () {
    return gulp.src(`build/rev-manifest.json`)
        .pipe($.revCollector({
            replaceReved: true,
            dirReplacements: {
                'js': function (manifest_value) {
                    return '//js.40017.cn/touch/hb/c/2/js/' + manifest_value;
                },
            }
        }))
        .pipe(gulp.dest('build/')) // write manifest to build dir
})
lobodol commented 5 years ago

Hi, I face the same issue. Here is my task's code :

gulp.task('revision', function () {
    return gulp.src('web/manifest.json')
        .pipe(revCollector({
            replaceReved: true,
            dirReplacements: {
                '': function(manifest_value) {
                    manifest_value = 'build/assets/' + manifest_value;
                    console.log(manifest_value);
                    return manifest_value;
                }
            }
        }))
        .pipe( gulp.dest('web') );
});

I can see my console.log in the terminal output but the file manifest.json keeps unchanged.

Am I using it wrong ?

shonny-ua commented 5 years ago

Yes. gulp-rev-collector does not change manifest.json content. manifest.json is a config for changes in other, not *.json files.

lobodol commented 5 years ago

Well, in your previous comment you've written :

gulp.task("rev", function () {
    return gulp.src(`build/rev-manifest.json`)
        .pipe($.revCollector({
            replaceReved: true,
            dirReplacements: {
                'js': function (manifest_value) {
                    return '//js.40017.cn/touch/hb/c/2/js/' + manifest_value;
                },
            }
        }))
        .pipe(gulp.dest('build/')) // write manifest to build dir
})

.pipe(gulp.dest('build/')) // write manifest to build dir

I don't understand: does it write manifest or not ?

shonny-ua commented 5 years ago

return gulp.src(['rev/*/.json', 'templates/*/.html'])