【问题标题】:Slow grunt watch慢咕咕手表
【发布时间】:2016-01-11 16:03:57
【问题描述】:

我在 Windows 7 Professional 系统上设置了一个简单的 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']);

}

如果我启动 grunt,一切正常,但速度很慢。完成这三项任务最多需要 15 秒:

slow grunt

是不是我做错了什么?

【问题讨论】:

  • 任务完成时间取决于您的 PC 功率,但 grunt 在旧机器上运行缓慢,请使用 gulp。 gulp 比 grunt 快得多
  • 15 秒对于这些任务来说并不算长。占用大部分时间的可能是 sftp 任务,因为它涉及通过 sftp 上传目录中的所有文件。

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


【解决方案1】:

原文出自: https://github.com/gruntjs/grunt-contrib-watch/issues/69

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    • 2014-07-13
    • 1970-01-01
    相关资源
    最近更新 更多