Skip to content

Commit bc83d46

Browse files
update pug task
1 parent b498e81 commit bc83d46

File tree

1 file changed

+26
-37
lines changed
  • generators/app/templates/gulp/tasks

1 file changed

+26
-37
lines changed

generators/app/templates/gulp/tasks/pug.js

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,31 @@
1-
var gulp = require('gulp');
2-
var pug = require('gulp-pug');
3-
var plumber = require('gulp-plumber');
4-
var changed = require('gulp-changed');
5-
var gulpif = require('gulp-if');
6-
var frontMatter = require('gulp-front-matter');
7-
var prettify = require('gulp-prettify');
8-
var config = require('../config');
9-
10-
function renderHtml(onlyChanged) {
11-
return gulp
12-
.src([config.src.templates + '/[^_]*.pug'])
13-
.pipe(plumber({ errorHandler: config.errorHandler }))
14-
.pipe(gulpif(onlyChanged, changed(config.dest.html, { extension: '.html' })))
15-
.pipe(frontMatter({ property: 'data' }))
16-
.pipe(pug())
17-
.pipe(prettify({
18-
indent_size: 2,
19-
wrap_attributes: 'auto', // 'force'
20-
preserve_newlines: true,
21-
// unformatted: [],
22-
end_with_newline: true
23-
}))
24-
.pipe(gulp.dest(config.dest.html));
1+
import gulp from 'gulp';
2+
import pug from 'gulp-pug';
3+
import plumber from 'gulp-plumber'
4+
import changed from 'gulp-changed';
5+
import gulpif from 'gulp-if';
6+
import frontMatter from 'gulp-front-matter';
7+
import prettify from 'gulp-prettify';
8+
import config from '../config';
9+
10+
const renderHtml = (onlyChanged) => {
11+
return gulp
12+
.src([config.src.templates + '/[^_]*.pug'])
13+
.pipe(plumber({ errorHandler: config.errorHandler }))
14+
.pipe(gulpif(onlyChanged, changed(config.dest.html, { extension: '.html' })))
15+
.pipe(frontMatter({ property: 'data' }))
16+
.pipe(pug())
17+
.pipe(prettify({
18+
indent_size: 2,
19+
wrap_attributes: 'auto', // 'force'
20+
preserve_newlines: true,
21+
// unformatted: [],
22+
end_with_newline: true
23+
}))
24+
.pipe(gulp.dest(config.dest.html));
2525
}
2626

27-
gulp.task('pug', function() {
28-
return renderHtml();
29-
});
30-
31-
gulp.task('pug:changed', function() {
32-
return renderHtml(true);
33-
});
34-
35-
gulp.task('pug:watch', function() {
36-
gulp.watch([config.src.templates + '/**/_*.pug'], ['pug']);
37-
gulp.watch([config.src.templates + '/**/[^_]*.pug'], ['pug:changed']);
38-
});
39-
27+
gulp.task('pug', () => renderHtml());
28+
gulp.task('pug:changed', () => renderHtml(true));
4029

4130
const build = gulp => gulp.parallel('pug');
4231
const watch = gulp => {

0 commit comments

Comments
 (0)