# gulp-prefix

> Implementation of html-prefixer for gulp

Latest version **0.0.15** (published 2016-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-prefix
pnpm add gulp-prefix
yarn add gulp-prefix
bun add gulp-prefix
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2016-04-17 |
| First published | 2014-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | 007design |
| Maintainers | 007design |
| Keywords | gulpplugin, prefix, replace, path, tag, html, css, script, url |

## Links

- npm: https://www.npmjs.com/package/gulp-prefix
- Repository: https://github.com/007design/gulp-prefix
- Issues: https://github.com/007design/gulp-prefix/issues
- npm.io page: https://npm.io/package/gulp-prefix

## Dependencies (5)

- [url](https://npm.io/package/url.md) ~0.10.1
- [trumpet](https://npm.io/package/trumpet.md) ~1.7.0
- [through2](https://npm.io/package/through2.md) ~1.0.0
- [url-join](https://npm.io/package/url-join.md) 0.0.1
- [concat-stream](https://npm.io/package/concat-stream.md) ~1.4.5

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.0.15 (latest) — 2016-04-17
- 0.0.14 — 2015-03-18
- 0.0.13 — 2014-11-06
- 0.0.12 — 2014-10-13
- 0.0.11 — 2014-08-28
- 0.0.10 — 2014-08-05
- 0.0.9 — 2014-08-04
- 0.0.8 — 2014-08-04
- 0.0.7 — 2014-07-09
- 0.0.6 — 2014-07-02
- 0.0.5 — 2014-04-28
- 0.0.4 — 2014-04-24
- 0.0.3 — 2014-04-23
- 0.0.2 — 2014-04-23
- 0.0.1 — 2014-04-22

## README

gulp-prefix
=========
[![Build Status](https://travis-ci.org/007design/gulp-prefix.svg?branch=master)](https://travis-ci.org/007design/gulp-prefix)

A gulp plugin inspired by [html-prefixer](https://github.com/tivac/node-html-prefixer).

Will prefix relative urls in &lt;link&gt;, &lt;script&gt; and &lt;img&gt; tags

You can optionally pass a second argument along with the prefix string to override the default selection statements.
The default config looks like this:

```
[
  { match: "script[src]", attr: "src" },
  { match: "link[href]", attr: "href"},
  { match: "img[src]", attr: "src"},
  { match: "input[src]", attr: "src"}
]
```


If you have tags which you do not want to prefix, you can pass a third argument containing a regular expression string which, if matched against the attribute, will ignore the tag.  


###HTML
```html
<html>
  <head>
    <link href="http://cdnjs.com/some-library.css">
    <link href="css/stylesheets.css">
  </head>
  <body>
    <img src="/images/myImage.jpg"/>
    <script src="//cdnjs.com/some-library.js"></script>
    <script src="js/scripts.js"></script>
    <script src="{{ignore_me_i_am_mustache}}"></script>
  </body>
</html>
```



###Usage
```javascript
var gulp = require('gulp'),
    prefix = require('gulp-prefix');

gulp.task('prefix', function(){
  var prefixUrl = "http://mydomain.com/assets";

  gulp.src('index.html')
    .pipe(prefix(prefixUrl, null, '{{'))
    .pipe(gulp.dest('build'));
});
```

###Output
```html
<html>
  <head>
    <link href="http://cdnjs.com/some-library.css">
    <link href="http://mydomain.com/assets/css/stylesheets.css">
  </head>
  <body>
    <img src="http://mydomain.com/assets/images/myImage.jpg"/>
    <script src="//cdnjs.com/some-library.js"></script>
    <script src="http://mydomain.com/assets/js/scripts.js"></script>
    <script src="{{ignore_me_i_am_mustache}}"></script>
  </body>
</html>
```

To run tests install jasmine-node globally `npm install jasmine-node -g` and run `jasmine-node spec`


License
----

MIT

---
_Source: https://npm.io/package/gulp-prefix · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
