我如何在 Gulp 中设置 Pug 的主目录
How i can setting the home directory for Pug in Gulp
我正在尝试使用以下代码将 Pug 的主目录设置为 Galp:
function renderPug() {
return src('app/pug/pages/**/*.pug')
.pipe(pug({
pretty: true,
basedir: __dirname,
}))
.pipe(dest('build'))
.on('end', browserSync.reload);
}
但是在做任务的时候,出现了这个错误:
ENOENT: no such file or directory, open '/Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/layout/templates/photos-inside.pug'
at /Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/photos.pug line 1
Details:
errno: -2
syscall: open
code: ENOENT
path: /Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/layout/templates/photos-inside.pug
domainEmitter: [object Object]
domainThrown: false
我做错了什么?
这对我有用:
const path = require('path');
function renderPug() {
return src('app/pug/pages/**/*.pug')
.pipe(pug({
pretty: true,
basedir: path.join(__dirname, 'app', 'pug'),
}))
.pipe(dest('./build'))
.on('end', browserSync.reload);
}
并且必须指定相对于根文件夹的文件路径:/layout/templates/photos-inside
。
我正在尝试使用以下代码将 Pug 的主目录设置为 Galp:
function renderPug() {
return src('app/pug/pages/**/*.pug')
.pipe(pug({
pretty: true,
basedir: __dirname,
}))
.pipe(dest('build'))
.on('end', browserSync.reload);
}
但是在做任务的时候,出现了这个错误:
ENOENT: no such file or directory, open '/Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/layout/templates/photos-inside.pug'
at /Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/photos.pug line 1
Details:
errno: -2
syscall: open
code: ENOENT
path: /Users/Boboshko/boboshko-me/app/pug/pages/photos/russia/moscow/2019/layout/templates/photos-inside.pug
domainEmitter: [object Object]
domainThrown: false
我做错了什么?
这对我有用:
const path = require('path');
function renderPug() {
return src('app/pug/pages/**/*.pug')
.pipe(pug({
pretty: true,
basedir: path.join(__dirname, 'app', 'pug'),
}))
.pipe(dest('./build'))
.on('end', browserSync.reload);
}
并且必须指定相对于根文件夹的文件路径:/layout/templates/photos-inside
。