I'm trying to automatically upload a .css
file, when it's compiled from Sass. This is what I've got in my 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']);
};
It compiles the .css
but doesn't seem to upload it. Any ideas?
I would like to confirm that the following grunt-ssh (https://github.com/andrewrjones/grunt-ssh) task config worked fine for me. Note that grunt accepts --verbose option which may help debug. Note that as of v0.6.2 grunt-ssh SFTP task did not seem to support sshconfig syntax, which was not very clear from the help page.
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
}
}
}
I was trying to do something almost identical using grunt-sftp and ran into similar errors. The logging wasn't the greatest so I ended up using grunt-shell and just ran scp
upon compilation:
watch: {
tumblr: {
files:['sass/*.scss', 'sass/*/*.scss'],
tasks: [ 'compass:tumblr', 'shell:tumblr' ]
}
},
shell: {
tumblr: {
command: 'scp -P 2222 -r stylesheets "[email protected]:/var/www/foo/directory"'
}
}
This worked like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With