Lan*_*opp 22 javascript node.js gruntjs
我正在尝试配置我的Gruntfile以将我的所有Jade文件编译为单独的HTML文件.例如,如果我有以下源文件夹:
source
??? templates
??? first.jade
??? second.jade
??? third.jade
Run Code Online (Sandbox Code Playgroud)
然后我希望grunt jade输出:
build
??? templates
??? first.html
??? second.html
??? third.html
Run Code Online (Sandbox Code Playgroud)
这是我的Gruntfile使用grunt-contrib-jade:
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");
};
Run Code Online (Sandbox Code Playgroud)
但是,当我运行jade命令时,我收到以下错误:
Running "jade:compile" (jade) task
>> Source file "first.jade" not found.
>> Source file "second.jade" not found.
>> Source file "third.jade" not found.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
小智 50
完成上述答案
jade: {
compile: {
options: {
client: false,
pretty: true
},
files: [ {
cwd: "app/views",
src: "**/*.jade",
dest: "build/templates",
expand: true,
ext: ".html"
} ]
}
}
Run Code Online (Sandbox Code Playgroud)
因此,如果您的来源结构如下:
app
??? views
??? main.jade
??? user
??? signup.jade
??? preferences.jade
Run Code Online (Sandbox Code Playgroud)
grunt jade 将创建以下结构
build
??? templates
??? main.html
??? user
??? signup.html
??? preferences.html
Run Code Online (Sandbox Code Playgroud)
编辑:grunt-contrib-jade已弃用.你应该宁愿使用grunt-contrib-pug.它完全一样,但他们不得不将玉重命名为哈巴狗!
| 归档时间: |
|
| 查看次数: |
15299 次 |
| 最近记录: |