【发布时间】:2021-10-06 21:20:42
【问题描述】:
我正在学习使用 gulp,我决定使用 pug 来编写我所有的 html。
事情是有这个文件夹结构:
src/pug
├── base
│ ├── mixins.pug
│ └── variables.pug
├── components
│ ├── footer.pug
│ ├── header.pug
│ ├── head.pug
│ └── template.pug
├── index.pug
└── views
└── about.pug
我希望 gulp 忽略所有不是 index.html 的文件以及我在 views 文件夹中的所有文件。
我正在使用此配置进行此操作:
function compilePug() {
return src(['./src/pug/index.pug','./src/pug/views/*.pug'], {base: './src/pug/'})
.pipe(pug().on("error", console.log))
.pipe(
pug({
// Your options in here.
})
)
.pipe(dest('./dist/'));
};
问题是,就像这样创建和输出dist/views/about.html。
但我宁愿生成类似 dist/about/index.html 的内容。这样我可以在多个页面之间导航,而无需在末尾添加 .html 扩展名。
这可能吗?
【问题讨论】: