gulp-relative-replace

0.0.6 • Public • Published

gulp-relative-replace

NPM version Download stats

NPM stats

Replace build placeholder to relative path.

Table of Contents

Usage

Install:

npm install --save-dev gulp-relative-replace

API

relativeReplace(options)

options

Type: object

  • {String} placeholder - The placeholder you want to replace. Default: @___RELATIVE_REPLACE_HOLDER__@
  • {String} from - The path relative from.
  • {String} to - The path relative to.
Options example:
relativeReplace({
  form : './build/'
})

Example

index.html:

<!DOCTYPE html>
<html>
    <head>
  
    <link rel="stylesheet" href="@___RELATIVE_REPLACE_HOLDER__@normalize.css">
    </head>
    <body>
 
    <img src="@___RELATIVE_REPLACE_HOLDER_2__@bg.jpg">
 

gulpfile.js:

var gulp = require('gulp');
var relativeReplace = require('gulp-relative-replace');
 
gulp.task('default', function() {
  gulp.src('index.html')
    .pipe(relativeReplace({
      to './build/html/css' //build/html -> /build/html/css
    }))
    .pipe(relativeReplace({
      placeholder : '@___RELATIVE_REPLACE_HOLDER_2__@',
      from './build/imgs' // build/imgs -> build/html
    }))
    .pipe(gulp.dest('build/html'));
});

Result:

<!DOCTYPE html>
<html>
    <head>
 
    <link rel="stylesheet" href="css/styles.min.css">
 
    </head>
    <body>
  
    <img src="../imgs/bg.jpg">

Readme

Keywords

none

Package Sidebar

Install

npm i gulp-relative-replace

Weekly Downloads

1

Version

0.0.6

License

MIT

Last publish

Collaborators

  • smildlzj