GruntJS indicates environment-based logical configuration

I have a Gruntfile that looks something like this (simplified for example):

 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' 

The problem is that grunt-config (or perhaps a pattern parsing) converts all its parameters to strings, but the Jade compiler checks all its logical flag parameters as booleans ( if (compileDebug !== false) ). Therefore, even when running grunt config:dist jade it still generates templates with debugging logic turned on.

I know that I can get around this by duplicating the Jade configuration for two different purposes, but I would like my Gruntfile to be as dry as possible. Is there any way to do this?

+4
source share
1 answer

I could not find any way to do this, so I made a grunt plugin with functionality here:

https://npmjs.org/package/grunt-reconfigure

0
source

Source: https://habr.com/ru/post/1490945/


All Articles