简体   繁体   English

Grunt - 使用Pug插件编译多个Jade文件

[英]Grunt - Compile Multiple Jade Files using the Pug plugin

I have a Laravel directory structure and I have my Jade templates in the /resources/assets/jade/ folder. 我有一个Laravel目录结构,我在/ resources / assets / jade /文件夹中有我的Jade模板。

Inside this folder will have multiple sub-directories which I will need to copy their exact structure to the /public/app/ directory where my app will be served from.. 在这个文件夹里面会有多个子目录,我需要将它们的确切结构复制到我的应用程序所在的/ public / app /目录中。

I have also got Typescript files being compiled into the same directory structure so its very important that the directory layout is copied as I have set it up.. I cant seem to do this successfully using the Grunt Pug plugin.. any help greatly appreciated, heres what I have so far: 我也将Typescript文件编译成相同的目录结构,因此在我设置它时复制目录布局非常重要..我似乎无法使用Grunt Pug插件成功地做到这一点..任何帮助非常感谢,继续我到目前为止所拥有的:

        module.exports = function(grunt) {
          grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            pug: {
                    compile: {
                        options: {
                            client: false,
                            pretty: true,
                            data: {
                                debug: false
                            }
                        },
                        files: [{
                            'public/app/index.html': ['resources/assets/jade/index.jade']
                        },
                        {
                            src: "resources/assets/jade/*.jade",
                            dest: "public/app",
                            expand: true,
                            ext: ".html"
                        } ]
                    }
                },
          });
          grunt.loadNpmTasks('grunt-contrib-pug');
          grunt.registerTask('default', ['pug'] );

        };

Looks like the old grunt-contrib-jade syntax works with PUG although I didnt see it documented anywhere so for dexterity heres what works perfectly: 看起来旧的grunt-contrib-jade语法可以与PUG一起工作,虽然我没有看到它记录在任何地方,所以对于灵巧heres什么工作完美:

        module.exports = function(grunt) {
          grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            pug: {
                   compile: {
                        options: {
                            client: false,
                            pretty: true
                        },
                        files: [ {
                          cwd: "resources/assets/jade",
                          src: "**/*.jade",
                          dest: "public/app",
                          expand: true,
                          ext: ".html"
                        } ]
                    }   
                },
          });
          grunt.loadNpmTasks('grunt-contrib-pug');
          grunt.registerTask('default', ['pug'] );

        };

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

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