简体   繁体   English

咕 包含子级(_ *。jade)时编译所有.jade文件

[英]Grunt. Compile all .jade files when child (_*.jade) included

I have next structure: 我有下一个结构:

jade
├── _skeleton.jade
├── _header.jade
├── _footer.jade
|
├── includes
│ └── _include-on-index.jade
│ └── _include-on-page-1.jade
│ └── _include-on-all-pages.jade
|
├── pages
│ └── index.jade
│ └── page-1.jade
│ └── page-2.jade
│ └── page-3.jade

And I need to setup jade compile, like some apps, (for example Prepros). 而且我需要像一些应用程序一样设置玉器编译(例如Prepros)。

It means that if I edit page-3.jade I need compile only page-3.jade, if I edit file that start with _ .jade, I don`t need compile exectly this _ .jade file like html, but I need to compile all .jade files that included this _*.jade file 这意味着,如果我编辑page-3.jade,我只需要编译page-3.jade,如果我编辑以_ .jade开头的文件,则不需要像html 这样专门编译_ .jade文件,但是我需要编译包含此_ *。jade文件的所有.jade文件

For example when I edit file _header.jade, I need compile all files that included _header.jade, if I edit _include-on-index.jade I need to compile file without _ that included _include-on-index.jade 例如,当我编辑文件_header.jade时,我需要编译包含_header.jade的所有文件,如果我编辑_include-on-index.jade我需要编译不包含_的文件,其中_包含_include-on-index.jade

Can I do this with Grunt? 我可以用Grunt做到吗?

you can use grunt-contrib-jade and grunt-contrib-watch and insert a watch for this jade files. 您可以使用grunt-contrib-jadegrunt-contrib-watch并为此手表插入一个手表。

so let's say everytime when you change a .jade file the watch will see this change and will compile your file. 因此,假设您每次更改.jade文件时,手表都会看到此更改并编译您的文件。

assuming i have this tree: 假设我有这棵树:

jade/templates with all my .jade files 我所有的.jade文件的翡翠/模板

jade/compiled-templates with all my compiled jade templates for .html jade / compiled-templates以及我为.html编译的所有Jade模板

config for jade: 翡翠的配置:

//Jade ===============================
            config.jade = {
                    compile: {
                        options: {
                            client: false,
                            pretty: true
                        },
                        files: [ {
                          cwd: "jade/templates",
                          src: "**/*.jade",
                          dest: "jade/compiled-templates",
                          expand: true,
                          ext: ".html"
                        } ]
                    }
                }

config for watch: 观看配置:

    //Watch ===============================

    config.watch = {
         scripts: {
            files: ["jade/**/*.jade"]
            ,tasks: ["dev"]
         }
    }

I hope this answer your question. 我希望这能回答您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM