Grunt serve - live reload只适用于app/*.html,而不适用于app/views/*.htm
grunt serve - live reload only works in app/*.html but not in app/views/*.html
我刚学会自耕农、咕噜咕噜和低头。我用yeoman做了一个angular应用程序,现在我试着编辑gruntfile.js。但是实时加载只适用于"app"文件夹中的文件。在像"app/views/"这样的文件夹中,它不会实时重新加载我的页面。grunt服务器注意到这个变化,我可以在控制台输出中看到这一点(文件"app'views'partial1.html"改变了),但没有实时加载发生。谁能告诉我怎么修?我谷歌了很多,但不知何故,我没有得到这个固定。这是我的手表部分在gruntfile.js:
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: '<%= connect.options.livereload %>'
}
},
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},
styles: {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
提前感谢您的帮助!!
用**/
替换所有的{,*/}
括号展开。所以代码应该是这样的:
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
js: {
files: ['<%= yeoman.app %>/scripts/**/*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: '<%= connect.options.livereload %>'
}
},
jsTest: {
files: ['test/spec/**/*.js'],
tasks: ['newer:jshint:test', 'karma']
},
styles: {
files: ['<%= yeoman.app %>/styles/**/*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/**/*.html',
'.tmp/styles/**/*.css',
'<%= yeoman.app %>/images/**/*.{png,jpg,jpeg,gif,webp,svg}'
]
}
作为参考,**
是一种globbing pattern。Grunt文档很好地描述了这一点:
大多数人需要知道的是
foo/*.js
将匹配foo/子目录中以.js结尾的所有文件,但foo/**/*.js
将匹配foo/子目录及其所有子目录中以.js结尾的所有文件。
相关文章:
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- PHP中的setcookie仅适用于localhost
- html5 drawImage适用于firefox,而不是chrome
- 提供“;onClick"适用于iPad(触摸屏)和桌面用户的默认功能
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- ResolveUrl是否适用于././也
- Firebase updateChildValues适用于IOS,但不适用于Web和Android
- JavaScript警报适用于int,但不适用于string
- SQLite插件适用于Mac和Windows,但不适用于手机上的Safari
- Regex Replace仅适用于Last Match
- window.onload适用于aspx页面,但不适用于普通html
- Jquery Ajax POST不工作.适用于GET
- 画布上的自定义字体仅适用于safari
- Javascript仅适用于alert()和Debug模式
- JS适用于Firefox和Safari,但不适用于Chrome.此处'是我的网站
- Regex不适用于Firefox,但适用于Chrome
- 通过单击主菜单外部关闭子菜单'不适用于IE,但适用于Firefox&铬
- AngularJS$http.post没有'不适用于Chrome,仅适用于IE
- 开始使用 Spotify API(适用于 Web App)
- Grunt serve - live reload只适用于app/*.html,而不适用于app/views/*.htm