2014-10-20 53 views
0

我使用grunt将一些jade文件编译成html文件。用grunt编译时保留文件夹结构

我的文件是这样的:

index.jade 
|--partials/ 
      view1.jade 
      view2.jade 

我用grunt-contrib-jade用下面的代码编译它们:

jade: { 
    compile: { 
    options: { 
     data: { 
     debug: true 
     } 
    }, 
    files: 
     [{ 
     expand: true, 
     cwd: 'src/', 
     src: ['*.jade', '*/*.jade'], 
     dest: 'dist/views', 
     ext: '.html', 
     }] 
    } 
}, 

它工作正常,所有的文件都编译但它打破了文件结构把所有的文件dist/views

有没有办法保持结构,即得到这样的东西?

dist/views 
|--------- index.html 
|---------/partials/ 
       /all other files 

非常感谢

回答

2

使用flatten属性:

files: 
    [{ 
    expand: true, 
    flatten: false, // <---- don't flatten the folder structure 
    cwd: 'src/', 
    src: ['**/*.jade'], // <---- also update your glob to grab all the .jade files at once 
    dest: 'dist/views', 
    ext: '.html', 
    }] 
相关问题