Node.js grunt processhtml删除在指定目标时不起作用
我是格伦特的新手。在使用grunt构建prod环境时,我试图从index.html页面中删除一段代码。这是我的密码:Node.js grunt processhtml删除在指定目标时不起作用,node.js,gruntjs,grunt-plugins,Node.js,Gruntjs,Grunt Plugins,我是格伦特的新手。在使用grunt构建prod环境时,我试图从index.html页面中删除一段代码。这是我的密码: <!-- build:remove --> <base href="/"></base> <!-- /build --> <title>Some App</title> <!-- build:css css/styles.min.css --> <link href="/app/cs
<!-- build:remove -->
<base href="/"></base>
<!-- /build -->
<title>Some App</title>
<!-- build:css css/styles.min.css -->
<link href="/app/css/header.css" rel="stylesheet" />
<link href="/app/css/content.css" rel="stylesheet" />
<!-- /build -->
<!-- build:js js/scripts.head.min.js -->
<script src="/app/lib/myApp.js"></script>
<script src="/app/lib/someApp.js"></script>
<!-- /build -->
下面是我如何配置processhtml的:
_processHtml =
options: strip: true
build: files: 'www/index.html': ['app/index.html']
如果我在index.html页面中添加prod target to build:remove语句,则不会删除html代码。但是,如果我不使用目标('prod'),那么HTML代码将被删除。对我来说,这似乎是倒退
因此,当我键入grunt build:prod时,这就起作用了-删除“base”标记:
<!-- build:remove -->
<base href="/"></base>
<!-- /build -->
当我键入grunt build:prod时,这不起作用-保留“base”标记:
<!-- build:remove:prod -->
<base href="/"></base>
<!-- /build -->
有什么想法吗?我该如何解决这个问题?要么是我的代码,要么是我的理解?谢谢。这是因为Grunt目标
build:prod
不存在
您已经定义了一个build
目标,但是您正在调用一个prod
目标。格伦特不知道这样的目标,因此什么也不做。在processhtml:build
之后放置的部分(即processhtml:build:prod)必须对应于Grunt目标
processhtml:
options: strip: true
prod: # <- note this target!
files: 'www/index.html': ['app/index.html']
processhtml:
选项:strip:true
prod:#您能发布完整的构建任务定义吗?那么,这一行grunt.task.run(“processhtml:build:{targetEnv}”)
在哪里?这是您的Grunfile中的完整processHtml
config吗?您的问题是什么?
processhtml:
options: strip: true
prod: # <- note this target!
files: 'www/index.html': ['app/index.html']