F
F
feelsgood2017-04-05 01:26:48
JavaScript
feelsgood, 2017-04-05 01:26:48

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"
}

Comrades, please tell me a plugin that could take the given one manifest.jsonand .htmlreplace 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

2 answer(s)
A
alex, 2017-04-05
@feelsgood

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();
});

E
Evgeny Kumanin, 2017-04-05
@jackkum

gulp injection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question