私は次のGruntfile
ようなものを持っています(例のために簡略化されています):
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'
問題はgrunt-config
(またはおそらくテンプレートの解析による) がすべてのオプションを文字列に変換することですが、Jade コンパイラはすべてのブール フラグ オプションをブール ( if (compileDebug !== false)
) としてチェックします。そのため、 を実行grunt config:dist jade
しても、デバッグ ロジックが含まれたテンプレートが生成されます。
Jade の設定を 2 つの異なるターゲットに複製することでこれを回避できることはわかっていますが、Gruntfile を可能な限り DRY に保ちたいと考えています。これを行う方法はありますか?