我有我的src/
目录如下:
src/
---about/
------history.pug
------mission.pug
---contact/
------email.pug
---index.pug
我希望我的 .pug 文件以这样一种方式编译,即它们即使在 dist/
目录中也能维护此目录层次结构。像这样:
dist/
---about/
------history.html
------mission.html
---contact/
------email.html
---index.html
我正在使用 Gulp 来处理哈巴狗文件。这可以通过使用gulp或其他方式的一项任务来实现吗?谢谢!
处理我的哈巴狗文件的 Gulp 任务:
gulp.task('pug', function() {
return gulp.src('src/pug/*.pug')
.pipe(pug({
basedir: "./"
}))
.pipe(gulp.dest('dist/html'));
})
gulp.task('pug', function() {
return gulp.src('src/**/*.pug')
.pipe(pug())
.pipe(gulp.dest('dist'));
})
会得到你的哈巴狗文件并将它们放在我认为你想要的地方。 在您的代码中,您有
.pipe(gulp.dest('dist/html'));
但是所需的 dist 文件夹结构中没有 HTML 文件夹。 与
gulp.src('src/pug/*.pug')
你的 src 目录没有 pug 子文件夹,那么为什么 src/pug 在这里?
另外我不认为 {basedir:....} 是哈巴狗插件的一个选项,所以我删除了它。