我是新来的咕噜声。在使用 grunt 构建我的 prod 环境时,我试图从我的 index.html 页面中删除一段代码。这是我的代码:
<!-- 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 -->
这是我的 gruntfile.coffee 代码:
grunt.task.run("processhtml:build:#{targetEnv}")
这是我配置processhtml的方式:
_processHtml =
options: strip: true
build: files: 'www/index.html': ['app/index.html']
如果我将 prod 目标添加到 index.html 页面中的 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 -->
有什么想法可以解决这个问题 - 无论是我的代码还是我的理解?谢谢你。