gulp-relative-replace
v0.0.6
Published
Replace build placeholder to relative path.
Downloads
2
Readme
gulp-relative-replace
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="@[email protected]">
</head>
<body>
<img src="@[email protected]">
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">