gulp-relative-replace
0.0.6 • Public • Published 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="@___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'
}))
.pipe(relativeReplace({
placeholder : '@___RELATIVE_REPLACE_HOLDER_2__@',
from './build/imgs'
}))
.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
nonePackage Sidebar
Install
npm i gulp-relative-replace
Weekly Downloads