0

使用 webapp 生成器,我创建了一个 yeoman 项目。我在“模板”目录的 app 文件夹中有一些 html 模板。运行 grunt build 时,我能够使这些文件得到更新;但是,我无法更新对“脚本”目录中 js 文件中 html 模板的引用。是否可以在 js 文件上使用 usemin 任务,还是首先修改 js 文件使用的 html 模板是个坏主意?

构建前:-root -app index.html -templates template1.html -scripts script1.js(使用template1.html)

构建后:-root index.html -templates 43643.template1.html -scripts 345345.script1.js(不更新 ref 到 template1.html)

我的 gruntfile 非常基本,只是在 rev 任务中添加了目录。任何建议,将不胜感激。提前致谢。

4

1 回答 1

0

您可以使用以下问题中的模式:Using grunt-usemin with dynamicly generated image paths

我用它来将修改后的 js 文件搜索到其他 js 文件中。

执行此操作时,请记住,您必须在其中写入所有相对路径,在我的情况下,我必须更改以下内容:

...
var file = basePath + 'filename.js';
...

...
var file = 'base/path/filename.js';
...

干杯,

于 2013-12-17T10:09:14.467 回答