简体   繁体   English

gulp 不创建任何目录

[英]gulp doesn't create any directory

My workspace is directory "Super gulp" and below, there is directories about my files.我的工作区是目录“Super gulp”,下面是关于我的文件的目录。 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.问题是我正在将 my.pug 文件转换为 html 文件,并将它们放在目录“goal”中,但是当我运行“dev”时没有任何结果。 I've tried method:( Gulp doesn't create folder? ) and found the result didn't changed.我试过方法:( Gulp 不创建文件夹? )发现结果没有改变。

文件目录

源代码

结果

Example to convert pug files into html files and put watcher on them.将 pug 文件转换为 html 文件并在其上放置 watcher 的示例。

Step: 1 -> First install npm packages for compiling pug and watch for changes步骤: 1 -> 首先安装 npm 包用于编译 pug 并注意更改

npm i -S gulp-pug gulp-watch

Step: 2 -> Then create and config your gulpfile.js.步骤:2 -> 然后创建并配置您的 gulpfile.js。

First import an npm modules首先导入一个npm模块

gulpfile.js 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 Step: 3 -> 运行下面的cmd来运行任务

gulp watch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM