N
N
Nikolai Shabalin2017-01-11 19:28:47
Pug
Nikolai Shabalin, 2017-01-11 19:28:47

How to compile pages of PUG files but not modules?

Have a project structure

src
  modules
    module-name
     module-name.pug
  pages
    index.pug
www
  html

module-name.pug
h1 Привет, мир.
index.pug
include ../modules/module-name/module-name.pug
Gulp task
const gulp          = require('gulp');
const pug           = require('gulp-pug');

gulp.task('pages', function() {
    return gulp.src(['src/**/*.pug'])
        .pipe(pug({
            doctype: 'html',
            pretty : true,
        }))
        .pipe(gulp.dest('www/html'))
});

It would be desirable:
1) that watch looked at all pug files. So that when ctrl+sa task is launched in a module or page.
2) to compile only pages src/pages/*.pug
I would not want to
1) to compile modules src/modules/**/*.pug
What I tried and failed
1) use pug-inheritence
2) use gulp-filter
There was an idea watchfor all pug files src/**/*.pug
Compiling them
Then filtering the unnecessary '!src/modules/**/*.html'
And already transferring files'www/html'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2017-01-11
@nikolayshabalin

const gulp = require('gulp');
const pug = require('gulp-pug');

gulp.task( 'pages', function() {
    return gulp.src( 'src/pages/*.pug' )
        .pipe(pug({
            doctype: 'html',
            pretty : true,
        }))
        .pipe(gulp.dest( 'www/html' ))
});

// watch [ 'src/pages/*.pug', 'src/modules/*/*.pug' ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question