rewrite path as absolute or relative
路径处理为绝对路径或相对路径
$ npm install --save-dev gulp-html-path
const gulp = require('gulp');
const gulpHtmlPath = require('gulp-html-path');
const sourcePath = 'source';
const src = ['source/**/*.html', 'source/**/*.js', 'source/**/*.css'];
const buildPath = 'dist';
gulp.task('replaceUrl', done => {
gulp
.src(src)
.pipe(gulpHtmlPath({ base: sourcePath, mode: 'absolute' }))
.pipe(gulp.dest(buildPath))
.on('end', () => {
done();
});
});
const gulp = require('gulp');
const gulpHtmlPath = require('gulp-html-path');
const sourcePath = 'source';
const src = ['source/**/*.html', 'source/**/*.js', 'source/**/*.css'];
const buildPath = 'dist';
gulp.task('replaceUrl',function(){
return gulp.src(src)
.pipe(gulpHtmlPath({base: sourcePath, mode: 'absolute'}))
.pipe(gulp.dest(buildPath))
});
Type: string
Default: ./
base path of frontend source code
Type: string
Default: absolute
build path mode ['absolute'|'relative']
Type: string
Default: ``
add the prefix string to each replacement
Type: boolean
Default: false
show detail logs
Type: string
Default: ./
前端源码目录
Type: string
Default: absolute
生成路径模式 ['absolute'|'relative']
Type: string
Default: ``
添加前缀
Type: boolean
Default: false
显示更多详细日志