2017-08-30 5 views

答えて

2

はあなたがgulp-html-replaceを使用することができますindex.htmlをがぶ飲みを使用して、私のhtmlファイルの本文の内容を削除する方法を誰もが知っている次のような構成

Gulp.js

var rename = require("gulp-rename"); 

gulp.task('modify-html', function() { 
    gulp.src('reports/index.html') 
    .pipe(rename('/app.html')) 
    .pipe(gulp.dest('reports/')); 
}); 

使用しますHTMLブロックを置き換えます。

マーク

<!-- build:remove --> 
Put all the content which needs to be removed, in the block 
<!-- endbuild --> 

とあなたがgulp-dom

var dom = require('gulp-dom'); 
gulp.task('modify-html', function() { 
    gulp.src('reports/index.html') 
    .pipe(dom(function() { 
      this.querySelector('body').innerHTML = ''; 
      return this; 
     })) 
    .pipe(rename('/app.html')) 
    .pipe(gulp.dest('reports/')); 
}); 

注意を使用することができ、その後

var htmlreplace = require('gulp-html-replace') 
gulp.task('modify-html', function() { 
    gulp.src('reports/index.html') 
    .pipe(htmlreplace({ remove : '' })) 
    .pipe(rename('/app.html')) 
    .pipe(gulp.dest('reports/')); 
}); 

のようにそれを使う削除する必要があり内容:私は持っているがそれをテストしていない。

+0

あなたの答えをありがとうが、私はスクリプト自体を使用してボディコンテンツを削除したい、上記の私は手作業でいくつかの特別なコードを追加する必要があります。 –

+1

、素晴らしい仕事、ありがとう、その作業上の罰金 –

関連する問題