当我从Sass编译时,我正在尝试自动上传.css
文件。这就是我在Gruntfile.js
中所得到的:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
coffee: {
files: ['**/*.coffee'],
tasks: ['coffee']
},
scripts: {
files: ['**/*.scss'],
tasks: ['compass']
},
sftp: {
files: ['**/*.css'],
tasks: ['sftp-deploy']
}
},
coffee: {
compile: {
files: {
'testing.js': 'testing.coffee'
}
}
},
compass: {
dist: {
options: {
config: 'config.rb'
}
}
},
'sftp-deploy': {
build: {
auth: {
host: 'example.com',
port: 22,
authKey: 'key2'
},
src: 'styles/',
dest: 'styles/',
exclusions: ['**/.DS_Store'],
server_sep: '/'
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-sftp-deploy');
// Default task(s).
grunt.registerTask('default', ['watch']);
};
它编译.css
但似乎没有上传它。有什么想法吗?
答案 0 :(得分:2)
我想确认以下grunt-ssh(https://github.com/andrewrjones/grunt-ssh)任务配置对我来说很好。请注意,grunt接受--verbose选项,这可能有助于调试。请注意,从v0.6.2开始,grunt-ssh SFTP任务似乎不支持sshconfig语法,这在帮助页面中不是很清楚。
sftpCredentials: grunt.file.readJSON('sftp-credentials.json'),
sftp: {
deploy: {
files: {
"./": "deploy/**"
},
options: {
"path": "<%= sftpCredentials.path %>",
"host": "<%= sftpCredentials.host %>",
"username": "<%= sftpCredentials.username %>",
"port": "<%= sftpCredentials.port %>",
"password": "<%= sftpCredentials.password %>",
"srcBasePath": "deploy/",
"createDirectories": true
}
}
}
答案 1 :(得分:1)
我试图使用grunt-sftp做一些几乎相同的事情并遇到类似的错误。日志记录不是最好的,所以我最终使用grunt-shell并在编译时运行scp
:
watch: {
tumblr: {
files:['sass/*.scss', 'sass/*/*.scss'],
tasks: [ 'compass:tumblr', 'shell:tumblr' ]
}
},
shell: {
tumblr: {
command: 'scp -P 2222 -r stylesheets "myname@myserver.com:/var/www/foo/directory"'
}
}
这就像一个魅力。