Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options.replaceInExtensions #73

Open
weilinzung opened this issue May 5, 2017 · 12 comments
Open

options.replaceInExtensions #73

weilinzung opened this issue May 5, 2017 · 12 comments

Comments

@weilinzung
Copy link

weilinzung commented May 5, 2017

Hi,

options.replaceInExtensions Type: Array Default: ['.js', '.css', '.html', '.hbs']

For this, would this option support .json and .xml?
I add it to my gulp-rev code, every types list on the doc is working fine, except .json and .xml, all the revision images are not updating within the .json and .xml.

issue related to: https://github.com/sindresorhus/gulp-rev/issues/214

thanks!

@weilinzung
Copy link
Author

???

@auban
Copy link

auban commented Mar 27, 2018

Same problem

@TheDancingCode
Copy link
Contributor

TheDancingCode commented Mar 28, 2018

I tried reproducing weilinzung's case, but replacement in JSON files works just fine here. Could you provide the gulp task you're using, and your rev-manifest.json?

@weilinzung
Copy link
Author

weilinzung commented Mar 29, 2018

It is actual only export with revision name manifest-128fcfa762.json, but the image path inside of the .json& .xml would not change. If the xxx.js & xxx.csshas image path, it would actual changed and everything works fine.

Current Result:
manifest-128fcfa762.json

{
 "name": "App",
 "icons": [
  {
   "src": "\/android-icon-36x36.png",
   "sizes": "36x36",
   "type": "image\/png",
   "density": "0.75"
  },
  {
   "src": "\/android-icon-48x48.png",
   "sizes": "48x48",
   "type": "image\/png",
   "density": "1.0"
  },
  {
   "src": "\/android-icon-72x72.png",
   "sizes": "72x72",
   "type": "image\/png",
   "density": "1.5"
  },
  {
   "src": "\/android-icon-96x96.png",
   "sizes": "96x96",
   "type": "image\/png",
   "density": "2.0"
  },
  {
   "src": "\/android-icon-144x144.png",
   "sizes": "144x144",
   "type": "image\/png",
   "density": "3.0"
  },
  {
   "src": "\/android-icon-192x192.png",
   "sizes": "192x192",
   "type": "image\/png",
   "density": "4.0"
  }
 ]
}

browserconfig-653d077300.xml

<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/ms-icon-70x70.png"/>
<square150x150logo src="/ms-icon-150x150.png"/>
<square310x310logo src="/ms-icon-310x310.png"/>
<TileColor>#ffffff</TileColor></tile>
</msapplication>
</browserconfig>

Expected Result:
manifest-b58fcfa762.json

{
 "name": "App",
 "icons": [
  {
   "src": "\/android-icon-36x36-sd5sdffa12.png",
   "sizes": "36x36",
   "type": "image\/png",
   "density": "0.75"
  },
 ...
 ]
}

browserconfig-653d077300.xml

<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/ms-icon-70x70-xd5sdffa12.png"/>
...
<TileColor>#ffffff</TileColor></tile>
</msapplication>
</browserconfig>

@TheDancingCode
Copy link
Contributor

Yes, but can you show the gulp task that you're using? It's hard to guess what you're doing wrong otherwise.

@weilinzung
Copy link
Author

weilinzung commented Mar 29, 2018

sure.

var gulp = require('gulp');
var rev = require('gulp-rev');
var revReplace = require('gulp-rev-replace');

gulp.task("index", function() {
  return gulp.src(['_site/**/*.jpg','_site/**/*.png','_site/**/*.json','_site/**/*.js','_site/**/*.css','_site/**/*.xml'])
    .pipe(rev()) 
    .pipe(revReplace({
      replaceInExtensions: ['.js', '.css', '.html', '.hbs', '.json','.xml']
    }))
    .pipe(gulp.dest('_site'));
});

The default options.replaceInExtensions doesn't have .json & .xml, so I don't think it is supported and that is why I am asking to add those.

#74

thanks!

@TheDancingCode
Copy link
Contributor

The list of globs that you pass to gulp.src should be an array, like this:

gulp.src(['_site/**/*.jpg','_site/**/*.png','_site/**/*.json','_site/**/*.js','_site/**/*.css','_site/**/*.xml'])

@weilinzung
Copy link
Author

weilinzung commented Mar 30, 2018

I don't think that could make the .json & .xml works... It is about this plugin feature...

I try what you said, nothing really happens.

@TheDancingCode
Copy link
Contributor

Have you tried using a rev-manifest.json file as described here?

@weilinzung
Copy link
Author

weilinzung commented Mar 30, 2018

Yes. not working~
That idea is just to create a new reference JSON, doesn't change the value inside of the existing .json or .xml files.

I think you don't understand this issue is gulp-rev-replace that doesn't support .json & .xml extensions. Right now, only re-reference the file name but not re-reference the new filenames inside of .json & .xml.

@ghost
Copy link

ghost commented Mar 1, 2019

The problem is the list of FRONT_DELIMITERS and BACK_DELIMITERS in lib/replace.js addition of a < and a > allows it to work for XML files as well.

@TheDancingCode
Copy link
Contributor

@akixi-johnathonclark
Do you have examples of common xml lines in which a filename appears just after < or before >?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants