将jade文件保存为具有相同名称的html

时间:2014-09-05 22:12:59

标签: javascript gruntjs npm pug

尝试让jade将我的jade文件保存为HTML文件,同时保持相同的文件名。

因此文件views/index.jade应保存为dist/index.html

其他文件相同。

我正在使用grunt-contrib-jade

我的Gruntfile的玉配置:

module.exports = function(grunt){
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jade: {
      compile: {
        options: {
          pretty: true
        },
        files: {
          'dist/*.html': ['views/*.jade']
        }
      }
    }

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

但它只是将文件保存为*.html

1 个答案:

答案 0 :(得分:0)

我认为它正在做你要告诉它的事情。 试试这个来配置玉器任务:

jade: {
    compile: {
        options: {
            pretty: true
        },
        files: [{
            expand: true, // setting to true enables the following options
            cwd: '/jade', // src matches are relative to this path
            src: ['{,*/}*.jade'], // matches *.jade in cwd and 1 level down
            dest: 'dist/', // destination prefix
            ext: '.html' // replace existing extensions with this value
        }]
    }
}

here is是有关使用Grunt动态构建文件列表的一些信息。