gulp-rev
gulp-rev copied to clipboard
Issue in rev-manifest.json file path
I am using gulp-rev and it is working fine. But I have one issue. I have multiple gulp task and I want to keep track of all in rev-mainfest.json file so I am providing merge:true config in rev.manifest() but it is not creating the file on the path I am providing but at the root level of directory. Here is how I am providing the path:
.pipe(rev())
.pipe(gulp.dest('scripts/bundles/'))
.pipe(rev.manifest({
base: 'scripts/revisions/',
merge: true
}))
.pipe(gulp.dest('scripts/revisions/'));
What am I missing here. Also one more thing I have noticed that it only generates file when there is any change but in documentation it's written that we should also use gulp-changed. Why is that?
Same issue here.
Dependencies:
"gulp-rev": "^9.0.0", "gulp": "^4.0.0",
Example task:
const postcssPlugins = [
autoprefixer({
browsers: ['last 2 versions', 'ie 11']
})
];
const minifiedFileExtension = rename({
extname: '.min.css'
});
if (options.prod) {
postcssPlugins.push(cssnano);
}
gulp.src(config.paths.css.src)
.pipe(plumber())
.pipe(rev())
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(postCss(postcssPlugins))
.pipe(gulpIf(options.prod, minifiedFileExtension))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.css.dest))
.pipe(
browserSync.reload({
stream: true
})
)
.pipe(
rev.manifest('manifest.json', {
cwd: 'web/app/dist',
merge: true
})
)
.pipe(gulp.dest('web/app/dist'));
To follow up, it seems that if a manifest.json already exists then the manifest is merged and placed where expected, in this case web/app/dist. If a manifest.json does not exist then the manifest is placed in the root which Im guess is process.cwd() in my case.
Looks like using path solves this for me 🤔
rev.manifest('manifest.json', { path: 'web/app/dist', merge: true })
@iamjaredwalters I already solved this issue but thanks for the answer. Can you tell me one more thing is there any way to keep track of all files in rev-mainfest.json? Right now if we make change in js file and execute gulp command then it overrides the file name in rev-mainfest.json but I want to keep track of all files like:
{
"module-min.js": "module-min-a2720m2695.js",
"module-min.js": "module-min-asdasj2j3j3.js",
"module-min.js": "module-min-adskj2n311.js",
....
}