More gulp common plug-ins use please visit: gulp common plug-ins summary
gulp-beautify this is an asset using js-beautify beautify the plug.
Greater use of the document, please click visit gulp-beautify tool official website .
installation
A key installation much explanation
npm install --save-dev gulp-beautify
use
This is a plug-js-beautify a gulp.
var beautify = require('gulp-beautify');
gulp.task('beautify', function() {
return gulp
.src('./src/*.js')
.pipe(beautify.js({ indent_size: 2 }))
.pipe(gulp.dest('./public/'));
});
And js-beautify the same, you can use it for HTML and CSS :
var beautify = require('gulp-beautify');
gulp.task('beautify-html', function() {
return gulp
.src('./src/*.html')
.pipe(beautify.html({ indent_size: 2 }))
.pipe(gulp.dest('./public/'));
});
gulp.task('beautify-css', function() {
return gulp
.src('./src/*.css')
.pipe(beautify.css({ indent_size: 2 }))
.pipe(gulp.dest('./public/'));
});
gulp.task('beautify-js', function() {
// gulp-beautify导出与js-beautify编程访问相同
// 因此beautify()是beautify.js()
return gulp
.src('./src/*.js')
.pipe(beautify({ indent_size: 2 }))
.pipe(gulp.dest('./public/'));
});
Options
Any options are passed directly to the JS-the Beautify .