Grunt - view file and SFTP when it changes

I am trying to automatically download a .css file when it is compiled from Sass. This is what I have in 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 .css , but doesn't seem to load it. Any ideas?

+7
source share
2 answers

I would like to confirm that the following grunt-ssh task configuration ( https://github.com/andrewrjones/grunt-ssh ) did a great job with me. Note that grunt accepts the --verbose option, which can help debug. Note that with v0.6.2, the grunt-ssh SFTP task did not seem to support the sshconfig syntax, which was not very clear on 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 } } } 
+2
source

I tried to do something almost identical with grunt-sftp and ran into similar errors. The record was not the largest, so I ended up using grunt-shell and just executed scp when compiling:

 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"' } } 

It worked like a charm.

+1
source

All Articles