|
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)); |
25 | 25 | }
|
26 | 26 |
|
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)); |
40 | 29 |
|
41 | 30 | const build = gulp => gulp.parallel('pug');
|
42 | 31 | const watch = gulp => {
|
|
0 commit comments