慢咕噜的手表

时间:2016-01-11 16:03:58

标签: javascript node.js gruntjs grunt-contrib-watch

我在Windows 7专业版系统上设置了一个简单的grunt环境。这是我创建的gruntfile.js:



module.exports = function(grunt) {

	grunt.loadNpmTasks('grunt-contrib-compass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-sftp-deploy');

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		'sftp-deploy': {
			build: {
				auth: {
					host: '',
					port: 22,
					authKey: ''
				},
			cache: 'sftpCache.json',
			src: '/css',
			dest: '/public_html/css',
			exclusions: ['/css/**/.DS_Store', '/css/**/Thumbs.db', 'dist/tmp', '/css/dev', '/css/*.map'],
			serverSep: '/',
			localSep: '/',
			concurrency: 4,
			progress: true
			}
		},
		compass: {
			dist: {
				options: {
				sassDir: '/css/dev',
				cssDir: '/css',
				environment: 'production'
				}
			},
			dev: {
				options: {
				sassDir: '/css/dev',
				cssDir: '/css'
				}
			}
		},
		watch: {
			css: {
				files: '**/*.scss',
				tasks: ['compass:dev']
			},
			ftp: {
				files: 'css/*.css',
				tasks: ['sftp-deploy']
			}
		}
	});

	grunt.registerTask('default',['watch']);

}




如果我发出咕噜声,一切正常,但很慢。完成这三项任务最多需要15秒钟:

slow grunt

我有什么不对的吗?

1 个答案:

答案 0 :(得分:0)

最初取自: https://github.com/gruntjs/grunt-contrib-watch/issues/69

  

默认情况下,此监视任务将生成作为子进程运行的任务。   对于某些系统,尤其是在Windows上,它可能确实很慢。设置   选项:nospawn:是。

     

https://github.com/gruntjs/grunt-contrib-watch#optionsnospawn   https://github.com/gruntjs/grunt-contrib-watch#why-spawn-as-child-processes-as-a-default