replace js file

replace js file
This commit is contained in:
a-jie 2018-06-18 09:31:46 +08:00
parent de58aac3be
commit b6db687b94
3 changed files with 23 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,15 +1,24 @@
var map = require('map-stream'); var map = require('map-stream');
var vfs = require('vinyl-fs'); var vfs = require('vinyl-fs');
var replace = function (file, cb) { vfs.src(['./dist/css/*.css'])
.pipe(map(function (file, cb) {
var content = file.contents; var content = file.contents;
content = content.toString('utf8'); content = content.toString('utf8');
content = content.replace('/banner.jpg','../banner.jpg').replace('/font/','../font/') content = content.replace('/banner.jpg', '../banner.jpg').replace('/font/', '../font/')
file.contents = Buffer.from(content); file.contents = Buffer.from(content);
cb(null, file); cb(null, file);
}; }))
vfs.src(['./dist/css/*.css'])
.pipe(map(replace))
.pipe(vfs.dest('./dist/css/')); .pipe(vfs.dest('./dist/css/'));
vfs.src(['./dist/js/*.js'])
.pipe(map(function (file, cb) {
var content = file.contents;
content = content.toString('utf8');
content = content.replace('/data.yaml', '../data.yaml');
file.contents = Buffer.from(content);
cb(null, file);
}))
.pipe(vfs.dest('./dist/js/'));