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

false positive on 'document.documentElement.style.cssFloat' #56

Open
larrybotha opened this issue Mar 14, 2016 · 1 comment
Open

false positive on 'document.documentElement.style.cssFloat' #56

larrybotha opened this issue Mar 14, 2016 · 1 comment

Comments

@larrybotha
Copy link

Getting a false positive in a bundled js file for an external library that contains

document.documentElement.style.cssFloat

style.css is replaced with the rev'd string from the manifest, invalidating the bundle.

@raduserbanescu
Copy link

If you are still interested, this is a workaround I use. (Quick example code below)

Usually, in source code paths are in one of these forms (with variants, of course):

<script src="path/to/file.js"></script>
const libSrc = 'path/to/file.js';
.my-selector {
  background: url(path/to/image.png);
}

So, basically all paths that need to be replaced are followed by ", ' or ). We make sure the plugin replaces only matches that are followed by one of those characters.

gulpfile.js

const modifyOnlyThoseEndingWith = (ending) => {
  return (filename) => {
    // Other modifications specific to your build

    filename += ending;

    return filename;
  };
};

gulp.task('revision-replace', () => {
  // We need a stream to consume for each `gulp-rev-replace` call
  const manifest1 = gulp.src('path/to/rev-manifest.json');
  const manifest2 = gulp.src('path/to/rev-manifest.json');
  const manifest3 = gulp.src('path/to/rev-manifest.json');

  return gulp.src('build-dir/**')
    .pipe($.revReplace({
      manifest: manifest1,
      modifyUnreved: modifyOnlyThoseEndingWith('\''),
      modifyReved: modifyOnlyThoseEndingWith('\''),
    }))
    .pipe($.revReplace({
      manifest: manifest2,
      modifyUnreved: modifyOnlyThoseEndingWith('"'),
      modifyReved: modifyOnlyThoseEndingWith('"'),
    }))
    // Used for CSS url() notation
    .pipe($.revReplace({
      manifest: manifest3,
      modifyUnreved: modifyOnlyThoseEndingWith(')'),
      modifyReved: modifyOnlyThoseEndingWith(')'),
    }))
    .pipe(gulp.dest('build-dir'));
});

Inspired by this comment from Issue #47.

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

2 participants