Answer the question
In order to leave comments, you need to log in
Gulp plugin to rename filenames?
The project is going js and css. The build results in the following files:main.0f7713e1.css
main.0f7713e1.css.map
manifest.json
{
"main.css": "main.0f7713e1.css",
"main.css.map": "main.0f7713e1.css.map"
}
main.5d3a612435769f8aa7d9.js
main.5d3a612435769f8aa7d9.js.map
manifest.json
{
"main.js": "main.5d3a612435769f8aa7d9.js",
"main.js.map": "main.5d3a612435769f8aa7d9.js.map"
}
manifest.json
and .html
replace the file names in the specified ones.<link rel="stylesheet" href="path/to/main.css">
<link rel="stylesheet" href="path/to/main.0f7713e1.css">
Answer the question
In order to leave comments, you need to log in
gulp-rev-replace
const gulp = require('gulp');
const revReplace = require('gulp-rev-replace');
gulp.task('revision', (done) => {
const manifestFile = gulp.src('path/to/manifest.json');
gulp.src('public/*.html')
.pipe(revReplace({manifest: manifestFile}))
.pipe(gulp.dest('public'));
done();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question