Pug GruntJS基于环境指定布尔配置

Pug GruntJS基于环境指定布尔配置,pug,gruntjs,Pug,Gruntjs,我有一个Gruntfile,看起来像这样(例如简化): module.exports=(咕噜)-> grunt.initConfig 配置: 开发人员: 选项: 变量: 调试:正确 地区: 选项: 变量: 调试:false 玉: 模板: 选项: 客户:是的 编译错误:“” 文件夹: 'public/templates.js':['src/jade/templates/***.jade'] grunt.loadNpmTasks'grunt config' grunt.loadNpmTasks'gr

我有一个
Gruntfile
,看起来像这样(例如简化):

module.exports=(咕噜)->
grunt.initConfig
配置:
开发人员:
选项:
变量:
调试:正确
地区:
选项:
变量:
调试:false
玉:
模板:
选项:
客户:是的
编译错误:“”
文件夹:
'public/templates.js':['src/jade/templates/***.jade']
grunt.loadNpmTasks'grunt config'
grunt.loadNpmTasks'grunt contrib jade'
问题是,
grunt config
(或者可能是模板解析)将其所有选项转换为字符串,但Jade编译器正在将其所有布尔标志选项检查为布尔值(
if(compileDebug!==false)
)。因此,即使我运行
grunt config:dist jade
,它仍然会生成包含调试逻辑的模板


我知道我可以通过将Jade配置复制到两个不同的目标来解决这个问题,但是我希望我的Gruntfile尽可能保持干燥。有什么方法可以做到这一点吗?

我找不到任何方法可以做到这一点,所以我制作了一个grunt插件,其功能如下:


在meIt的cofeescript看来,这就是为什么看起来“破碎”的原因
module.exports = (grunt) ->
  grunt.initConfig

    config:
      dev:
        options:
          variables:
            debug: true
      dist:
        options:
          variables:
            debug: false

    jade:
      templates:
        options:
          client: true
          compileDebug: '<%= grunt.config.get("debug") %>'
        files:
          'public/templates.js': ['src/jade/templates/**/*.jade']

  grunt.loadNpmTasks 'grunt-config'
  grunt.loadNpmTasks 'grunt-contrib-jade'