[英]grunt serve - live reload only works in app/*.html but not in app/views/*.html
i'm new to yeoman, grunt and bower. 我是约曼,咕unt和凉亭的新手。 i made an angular app with yeoman and now i try to edit the gruntfile.js. 我与yeoman做了一个有角度的应用程序,现在我尝试编辑gruntfile.js。 But live reload only works for files which are in 'app' - folder. 但是实时重新加载仅适用于“ app”文件夹中的文件。 in folders like 'app/views/' it doesn't live reload my page. 在“ app / views /”之类的文件夹中,它不会实时重新加载我的页面。 grunt server takes notice of the change, i can see this in console output (File "app\\views\\partial1.html" changed.) but no live-reload happens. grunt服务器注意到了更改,我可以在控制台输出(文件“ app \\ views \\ partial1.html”已更改。)中看到此更改,但是没有实时重新加载发生。 can anyone tell me how to fix that. 谁能告诉我该如何解决。 i googled a lot but somehow i don't get this fixed. 我用谷歌搜索了很多,但是不知何故我没有解决这个问题。 this is my watch-part in gruntfile.js: 这是我在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}'
]
}
thx in advance for your help!! 提前感谢您的帮助!
Replace all your {,*/}
brace expansions with **/
. 将所有{,*/}
大括号扩展替换为**/
。 So the code should look like this: 因此,代码应如下所示:
// 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}'
]
}
For reference, **
is a type of globbing pattern. 作为参考, **
是一种球形模式。 The Grunt documentation describes this one nicely: Grunt文档很好地描述了这一点:
All most people need to know is that
foo/*.js
will match all files ending with .js in the foo/ subdirectory, butfoo/**/*.js
will match all files ending with .js in the foo/ subdirectory and all of its subdirectories. 大多数人需要知道的是foo/*.js
。js将匹配foo /子目录中所有以.js结尾的文件,但是foo/**/*.js
。js将匹配foo /子目录中所有以.js结尾的文件,并且其所有子目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.