jonkemp / jonkemp/gulp-useref

How can you return original path if path is not defined in build comments?

Open
#170 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
700
Forks
89
PR merge metrics
No merged PRs in 30d

Description

I am using gulp useref to replace my files in my index.html after I minify them. I can get useref to work when I pass a path, but I would like to have it keep the file's original path when I don't define a path. I know I could go through and add the build **path** comment to each file or that I could just run a task to minify all other files. That just seems crazy and pointless if useref can output the original path then this task to would do it all.

Also posted the question on Stackoverflow:
http://stackoverflow.com/questions/34794378/gulp-useref-how-can-you-return-original-path

Example - to note stripped code for example aka rel="".

HTML file:

```


```

this works bc path is defined and the files exist in the same folder.

```


```

Gulp Task:

```
gulp.task('css', function () {
return gulp.src('index.html')
.pipe(useref())
.pipe(minifyCss())
.pipe(gulp.dest('dist'));
});
```

Resulting HTML - the index.html file is outputed to the "dist" folder and the .css files are minified. This all works, but noticed the href = "replace" bc nothing was defiened in the comments for path, also a file named undefined is outputed in the dist folder:

```

```

and what I want is...

```

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.