Kravitz
Kravitz

Reputation: 2859

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.

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..

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:

        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'] );

        };

Upvotes: 1

Views: 1652

Answers (1)

Kravitz
Kravitz

Reputation: 2859

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:

        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'] );

        };

Upvotes: 0

Related Questions