是的,这是可能的。但是你必须改变你的 Gruntfile.js:
到:
livereload: {
options: {
open: 'http://localhost:9000/yourname.html',
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
如果您想使用 yeoman 角度生成器,它们不会更新与 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
或提供附加选项来配置名称。