2013-06-02 8 views
7

Sto tentando di caricare automaticamente un file .css, quando è compilato da Sass. Questo è quello che ho nel mio Gruntfile.js:Grunt - Guarda un file e SFTP quando è cambiato

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']); 

}; 

compila il .css ma non sembra caricarlo. Qualche idea?

+0

quale directory fa 'config.rb' restituisce il' css' compilato in? –

+0

non dovresti farlo localmente e poi spingere verso l'alto quando esegui un passo di costruzione? –

risposta

1

Stavo cercando di fare qualcosa di quasi identico usando grunt-sftp e ho incontrato errori simili. La registrazione non era il massimo così ho finito per usare grunt-shell e appena eseguito scp su di compilazione:

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

Questo ha funzionato come un fascino.

2

Vorrei confermare che la seguente configurazione del task grunt-ssh (https://github.com/andrewrjones/grunt-ssh) ha funzionato bene per me. Nota che grunt accetta l'opzione -verbose che può aiutare il debug. Si noti che a partire dal task grTP-ssh SFTP v0.6.2 non sembra supportare la sintassi sshconfig, che non era molto chiara dalla pagina di aiuto.

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 
      } 
     } 
    } 
+0

Con 'grunt-ssh', come si imposta l'orologio in modo che carichi solo i file che sono stati modificati? – mpen

+0

I file vengono caricati dal task grunt lanciato manualmente (lo uso per caricare le mie nuove build in una nuova cartella vuota). Vedo che hai creato una domanda separata per questo, spero che alla fine ci sarà una risposta! :) – sbat