fex-team / fis

Front-end Integrated Solution - 前端集成解决方案, 最新版请进入 FIS3 https://github.com/fex-team/fis3
http://fis.baidu.com
MIT License
2.96k stars 654 forks source link

deploy部署阶段字符串替换问题 #485

Closed itachime closed 9 years ago

itachime commented 9 years ago

deploy配置中设置了replace来替换字符串,编译的时候加了o参数,发现没有替换到,是因为压缩动作发现在布署之前么,替换字符串时在压缩过的文件中查找?如果是,如何避免,需要在压缩前替换字符串

oxUnd commented 9 years ago

嗯,确实是在压缩后最后进行的替换,如果要避免,可以在压缩前的某一个插件扩展点上扩展一个插件,比如现在已经有同学这么干了;

fis.config.set('modules.parser.js', [function Replacer(content, file, conf) {
  // some proc
  return content.replace(/some-reg/ig, "some-string");
}]);
itachime commented 9 years ago

@xiangshouding 好,再问个问题,能否只针对某一个文件来替换呢,这样可能执行效率会高点

oxUnd commented 9 years ago

可以,从 file 里面拿到 filepath 看是否你想处理的文件,或者用 roadmap.path 给特定文件设置某个属性,插件处理的时候从 file 获取这个属性,如果是你想用来替换的文件就替换

在 2015年5月14日,上午10:07,heysb notifications@github.com 写道:

@xiangshouding 好,再问个问题,能否只针对某一个文件来替换呢,这样可能执行效率会高点

— Reply to this email directly or view it on GitHub.

itachime commented 9 years ago

@xiangshouding 好,试过可行,不过没有你说的 filepath 属性,而是 realpath

oxUnd commented 9 years ago

啵一个,不要在意这些细节,哈哈

在 2015年5月14日,上午10:51,heysb notifications@github.com 写道:

@xiangshouding 好,试过可行,不过没有你说的 filepath 属性,而是 realpath

— Reply to this email directly or view it on GitHub.