我试图使用咕噜-预处理模块,但有困难,如果要工作。
这是我的gruntfile
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>但是当我运行的时候,调试ifdef之间的代码并没有被删除(尽管ifdef注释本身被删除了)
我有一种感觉,我错过了一些在文档中没有提到的关键步骤。
谢谢
发布于 2013-08-10 11:52:50
见文件:
@ifdef VAR / @endif --如果VAR被定义为 (typeof !== 'undefined'),它将包括封闭的块。
定义了DEBUG-Var (其值为布尔值),因此将包括您的块。彻底移除它,它应该能起作用:
options: {
context : {}
}https://stackoverflow.com/questions/18130059
复制相似问题