Reputation: 93
My workspace is directory "Super gulp" and below, there is directories about my files. The problem is that I was converting my .pug files into html files, and put them in directory "goal" but when I run "dev" nothing comes out. I've tried method:(Gulp doesn't create folder?) and found the result didn't changed.
Upvotes: 2
Views: 241
Reputation: 5098
Example to convert pug files into html files and put watcher on them.
Step: 1 -> First install npm packages for compiling pug and watch for changes
npm i -S gulp-pug gulp-watch
Step: 2 -> Then create and config your gulpfile.js.
First import an npm modules
gulpfile.js
const pug = require('gulp-pug');
const watch = require('gulp-watch');
//Then create compiling task
gulp.task('pug',() => {
return gulp.src('./src/*.pug')
.pipe(pug({
doctype: 'html',
pretty: false
}))
.pipe(gulp.dest('./src/goal/'));
});
//And then create watcher
gulp.task('watch',() => {
return watch('./src/*.pug', { ignoreInitial: false })
.pipe(gulp.dest('pug'));
});
Step: 3 -> Run the below cmd to run the task
gulp watch
Upvotes: 1