options.to 允许空字符
fis3-deploy-replace
npm install [-g] fis3-deploy-replace
fis.match('**', { deploy: [ fis.plugin('replace', { from: 'from/string', to: 'to/string' }), fis.plugin('local-deliver') //must add a deliver, such as http-push, local-deliver ] });
多字符串替换
fis.match('**', { deploy: [ fis.plugin('replace', { from: /(img|cdn)\.baidu\.com/, to: function ($0, $1) { switch ($1) { case 'img': return '127.0.0.1:8080'; case 'cdn': return '127.0.0.1:8081'; } return $0; } }), fis.plugin('local-deliver') ] });
或者
function replacer(opt) { if (!Array.isArray(opt)) { opt = [opt]; } var r = []; opt.forEach(function (raw) { r.push(fis.plugin('replace', raw)); }); return r; }; fis.match('*', { deploy: replacer([ { from: 'a', to: 'b', }, { from: 'a0', to: 'b0' } ]).concat(fis.plugin('local-deliver')); });
机智的你可能已经发现了点什么。我们配置了多个功能单一的 fis.plugin('replace')。
fis.plugin('replace')
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
fis3-deploy-replace
fis3-deploy-replace
INSTALL
USE
EXAMPLE
多字符串替换
或者
机智的你可能已经发现了点什么。我们配置了多个功能单一的
fis.plugin('replace')。