gpt4 book ai didi

javascript - Grunt 编译 Jade 文件

转载 作者:IT老高 更新时间:2023-10-28 22:05:09 26 4
gpt4 key购买 nike

我正在尝试配置我的 Gruntfile 以将我的所有 Jade 文件编译为单独的 HTML 文件。例如,如果我有以下源文件夹:

source
└── templates
   ├── first.jade
   ├── second.jade
   └── third.jade

然后我希望 grunt jade 输出:

build
└── templates
   ├── first.html
   ├── second.html
   └── third.html

这是我使用 grunt-contrib-jade 的 Gruntfile:

module.exports = function(grunt) {
grunt.initConfig({

jade: {
compile: {
options: {
client: false,
pretty: true
},
files: [ {
src: "*.jade",
dest: "build/templates/",
ext: "html",
cwd: "source/templates/"
} ]
}
},
});

grunt.loadNpmTasks("grunt-contrib-jade");
};

但是,当我运行 Jade 命令时,我收到以下错误:

Running "jade:compile" (jade) task
>> Source file "first.jade" not found.
>> Source file "second.jade" not found.
>> Source file "third.jade" not found.

我做错了什么?

最佳答案

完成以上答案

    jade: {
compile: {
options: {
client: false,
pretty: true
},
files: [ {
cwd: "app/views",
src: "**/*.jade",
dest: "build/templates",
expand: true,
ext: ".html"
} ]
}
}

因此,如果您的来源的结构是这样的:

app
└── views
└── main.jade
└── user
└── signup.jade
└── preferences.jade

grunt jade 将创建以下结构

build
└── templates
└── main.html
└── user
└── signup.html
└── preferences.html

编辑:grunt-contrib-jade 已弃用。你应该使用 grunt-contrib-pug。是一模一样的,不过他们得把 Jade 改名哈巴狗!

关于javascript - Grunt 编译 Jade 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17798358/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com