出于某种原因,当我的终端点击Running "watch" task
Completed in 3.131s at Wed Jun 17 2015 21:00:56... ...) - Waiting...
时它变得太慢了,我们说的是 1 分钟以上,然后它才会填充其余数据。
当我尝试通过 mongo-connector 将我的数据库同步到我的 elasticsearch 服务器时,它可能已经开始。
可能是我的 mongodb 减慢了一切吗? 有什么想法吗?
更新 这是我的 Grunt.js 文件中的 watch :
watch: {
injectJS: {
files: [
'<%= yeoman.client %>/{app,components}/**/*.js',
'!<%= yeoman.client %>/{app,components}/**/*.spec.js',
'!<%= yeoman.client %>/{app,components}/**/*.mock.js',
'!<%= yeoman.client %>/app/app.js'],
tasks: ['injector:scripts']
},
injectCss: {
files: [
'<%= yeoman.client %>/{app,components}/**/*.css'
],
tasks: ['injector:css']
},
mochaTest: {
files: ['server/**/*.spec.js'],
tasks: ['env:test', 'mochaTest']
},
jsTest: {
files: [
'<%= yeoman.client %>/{app,components}/**/*.spec.js',
'<%= yeoman.client %>/{app,components}/**/*.mock.js'
],
tasks: ['newer:jshint:all', 'karma']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
files: [
'{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css',
'{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html',
'{.tmp,<%= yeoman.client %>}/{app,components}/**/*.js',
'!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js',
'!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js',
'<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: true
}
},
express: {
files: [
'server/**/*.{js,json}'
],
tasks: ['express:dev', 'wait'],
options: {
livereload: true,
nospawn: true //Without this option specified express won't be reloaded
}
}
},
我有一个 client/assets/images/目录,其中包含数千张图像。这会导致速度放缓吗?
最佳答案
此观察者正在观看多少个文件!?
一个非常常见的误用是监视父文件夹,其中“node_modules”是子文件夹。因此,根据您使用的 Node 模块数量,此观察程序可能会监视数十万个 js 文件...
要点
1) 确保您的观察者没有观察“node_modules”文件夹。
2) 尽可能使用文件过滤器来仅观看您关心的文件。下面的示例仅监视 .less 文件。
// example of watcher for .less files only
watch('../Content', filter(/\.less$/, function (filename) {
console.log('file changed: ', filename);
}));
关于javascript - Grunt 运行并完成 "watch"任务后非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30905918/