它可能是 grunt-watch,当你有很多文件时,它会挤压你的 CPU。尝试禁用它并检查您的 cpu 是否达到正常使用(6-30%,取决于您的 cpu 和整体使用情况)。
为此,请转到tasks/register/default.js并'watch'从数组中删除。
module.exports = function (grunt) {
grunt.registerTask('default', ['compileAssets', 'linkAssets', 'watch']);
};
Run Code Online (Sandbox Code Playgroud)
如果您不想完全禁用 grunt watcher,请tasks/config/watch.js尝试排除包含大部分文件的文件夹,或者如果它们不在特定文件夹中,则将它们全部排除。
我将举例说明如何为此任务排除文件夹。只需!在要排除的路径之前添加一个。
module.exports = function(grunt) {
grunt.config.set('watch', {
// Some config you can ignore in this case
assets: {
// Assets to watch:
files: ['assets/**/*',
'tasks/pipeline.js', '!**/node_modules/**',
'!assets/folder-to-exlude/**' // <-- HERE IS THE EXCLUDED PATH
],
// More code
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
};
Run Code Online (Sandbox Code Playgroud)
我有一个类似的问题,这对我有用,让我知道它是否有效。