2014-10-03 38 views
1

我试图在目录中对所有文件进行模板化,并将结果放在bin/admin目录中,以使目标文件与源文件具有相同的名称。但是,data中的dest好像是文件的名称,不能指定为目标目录。Grunt:目标文件模板后与源文件名称相同

module.exports = function(grunt) { 
    grunt.initConfig({ 
    'template': { 
     'process-html-template': { 
     'options': { 
      'data': { 
      'api_url': 'My blog post' 
      } 
     }, 
     'files': { 
      'bin/admin/': ['src/admin/*'] // <-- Here 
     } 
     } 
    } 
    }); 

    grunt.loadNpmTasks('grunt-template'); 
    grunt.registerTask('default', ['template']); 
} 

我能做些什么,以模板上的所有文件的src/并把它们在目标文件夹具有相同名称的来源?我尝试使用bin/admin/*作为目的地,但只是在bin/admin中创建一个文件名为*的文件。我想避免手动列出源目录中的所有文件。

回答

2

我想通了。它是一个具有src和dest属性的对象。

module.exports = function(grunt) { 
    grunt.initConfig({ 
    'template': { 
     'process-html-template': { 
     'options': { 
      'data': { 
      'api_url': 'My blog post' 
      } 
     }, 
     'files': [ 
      { 
      expand:true, 
      src: 'src/admin/*', 
      dest: 'bin/admin/' 
      } 
     ] 
     } 
    } 
    }); 

    grunt.loadNpmTasks('grunt-template'); 
    grunt.registerTask('default', ['template']); 
} 
相关问题