Stinger8のテーマファイルをgulpのgulp-phtml-simple-compを使ってphp圧縮にかけたら、バージョンベクタの圧縮がうまくいかなかったので自分用のメモ。
参考gulp-phtml-simple-comp
目次
うまくいかなかった箇所
そのままphp圧縮したら、
【圧縮前】
1 2 3 |
<!--[if gt IE 8]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> |
がうまく圧縮されず、htmlタグから先が丸っと消えてしまい、そのあとの処理がうまく動かなくなってしまいました。
【圧縮後】
1 |
<!--[if gt IE 8]>以降のhtml; |
修正方法
結局header.phpをちょろっと修正するだけじゃダメそうだったので、gulp-replaceを使って圧縮直後に置換することにしました。
1 2 3 4 5 6 7 8 9 10 |
const phpComp = require('gulp-phtml-simple-comp'); const replace = require('gulp-replace'); gulp.task('php-comp', () => { return gulp.src(['header.php']) .pipe(phpComp()) //バージョンベクタの圧縮がうまくいかないのでreplaceで置換する .pipe(replace('<!--[if gt IE 8]>', '<!--[if gt IE 8]><!--><html <?php language_attributes(); ?>><!--<![endif]-->')) .pipe(gulp.dest(hogehoge/)); }); |
ちょっと危険なやり方ですが止む無し。。。