简体   繁体   English

Grunt-具有相同开始的Jade文件编译为单个文件

[英]Grunt - Jade files with same start compile into single file

I am using grunt-contrib-jade to compile my jade files. 我正在使用grunt-contrib-jade来编译我的玉文件。 The issue I'm having is that say for example I have the following files: 我遇到的问题是,例如,我有以下文件:

/views/user.html
/views/user.index.hmtl
/views/user.show.html

These will all be compiled and merged into: 这些都将被编译并合并为:

/views/user.html

Why is this happening? 为什么会这样呢? I want them to be in separate files like: 我希望它们位于单独的文件中,例如:

/views/user.html
/views/user.index.html
/views/user.show.html

Is there a way to accomplish this? 有没有办法做到这一点?

This is my config: 这是我的配置:

jade: {
  compile: {
    options: {
      pretty: true,
      data: {
        debug: false
      }
    },
    files: [{
      expand: true,
      cwd: '<%= yeoman.client %>',
      src: [
        '{app,components}/**/*.jade'
      ],
      dest: '.tmp',
      ext: '.html'
    }]
  }
}

You have to use rename instead of ext . 您必须使用rename而不是ext

This should works: 这应该工作:

jade: {
  compile: {
    options: {
      pretty: true,
      data: {
        debug: false
      }
    },
    files: [{
      expand: true,
      cwd: '<%= yeoman.client %>',
      src: [
        '{app,components}/**/*.jade'
      ],
      dest: '.tmp',
      rename  : function (dest, src) {
        var folder    = src.substring(0, src.lastIndexOf('/'));
        var filename  = src.substring(src.lastIndexOf('/'), src.length);

        filename  = filename.substring(0, filename.lastIndexOf('.'));

        return dest + folder + filename + '.min.js';
      }
    }]
  }
}

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

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