Node.js 使用grunt预处理的问题

Node.js 使用grunt预处理的问题,node.js,gruntjs,Node.js,Gruntjs,我正在尝试使用grunt预处理模块,但很难让ifdef正常工作 这是我的文件 module.exports = function(grunt) { // Configuratuion goes here grunt.initConfig({ preprocess : { options: { context : { DEBUG: false } }, html : { src : 'dev/index.htm

我正在尝试使用grunt预处理模块,但很难让ifdef正常工作

这是我的文件

module.exports = function(grunt) {
// Configuratuion goes here

grunt.initConfig({

  preprocess : {

    options: {
      context : {
        DEBUG: false
      }
    },

    html : {
      src : 'dev/index.html',
      dest : 'dev/index.processed.html'
    }

  }
});

grunt.loadNpmTasks('grunt-preprocess');
grunt.registerTask('default', ['preprocess']);
}
这是我的html

<!DOCTYPE html>
<html>
<head>
</head>
<body>

<div id="wrap">

<!-- @ifdef DEBUG -->
  <h1>Test Page</h1>
<!-- @endif -->

<!-- @exclude -->
<header>You're on dev!</header>
<!-- @endexclude -->

<p>Test Pragraph</p>

<div id="output"></div>

</div>

</body>
</html>

测试页
你在看德夫!
测试曲线图

但是当我运行grunt时,调试ifdef之间的代码不会被删除(尽管ifdef注释本身也会被删除)

我有一种感觉,我错过了一些文档中没有提到的关键步骤

谢谢

请参阅文档:

@ifdef VAR/@endif
如果定义了VAR(typeof!=='undefined'),这将包括封闭的块

您的
DEBUG
-Var已定义(其值为布尔值),因此将包括您的块。完全移除它,它应该可以工作:

options: {
  context : {}
}