是的,這是可能的。但是,你必須改變你的Gruntfile.js:從
到:
livereload: {
options: {
open: 'http://localhost:9000/yourname.html',
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
如果你想使用yeoman angular generato rs,他們不會更新與index.html不同的文件,因爲index.html在生成器中被硬編碼。只有一個命令行參數(--skip-add
)可防止生成器觸及index.html文件。
當然。它是開源的。相關部分是在文件中:https://github.com/yeoman/generator-angular/blob/master/script-base.js
Generator.prototype.addScriptToIndex = function (script) {
try {
var appPath = this.env.options.appPath;
var fullPath = path.join(appPath, 'index.html');
angularUtils.rewriteFile({
file: fullPath,
needle: '<!-- endbuild -->',
splicable: [
'<script src="scripts/' + script.toLowerCase().replace('\\', '/') + '.js"></script>'
]
});
} catch (e) {
console.log('\nUnable to find '.yellow + fullPath + '. Reference to '.yellow + script + '.js ' + 'not added.\n'.yellow);
}
};
您可以更改名稱index.html
或提供額外的選項來配置的名稱。
唯一的問題是grunt + bower不知道在哪裏寫文件了。在grunt將文件包含到index.html之前,現在它不會這樣做。 –
@EdgarMartinez你是什麼意思:「在哪裏寫文件」?哪些文件? – michael
對不起,讓我更具體。我更新了這個問題,希望能夠澄清。 –