Skip to content

Instantly share code, notes, and snippets.

@BGundlach
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BGundlach/80e36e33c63b3db3b8a7 to your computer and use it in GitHub Desktop.
Save BGundlach/80e36e33c63b3db3b8a7 to your computer and use it in GitHub Desktop.
Gruntfile for syncing between localhost and remote server
module.exports = function(grunt) {
grunt.initConfig({
rsync: {
options: {
args: ["--verbose"],
exclude: [".git*", "*.scss", "node_modules", "concrete"],
recursive: true
},
dev: {
options: {
src: "./",
dest: "/path/to/coresponding/folder/<%= rsync.dev.options.src %>",
host: "username@serverDomainOrIP",
syncDestIgnoreExcl: true
}
},
get: {
options: {
src: "<%= rsync.dev.options.host %>:<%= rsync.dev.options.dest %>",
dest: "<%= rsync.dev.options.src %>",
syncDestIgnoreExcl: true
}
},
},
watch: {
upload: {
// Dont spawn to retain the process context here
options: {
spawn: false
},
files: ['**/*'],
tasks: ['rsync:dev']
},
},
});
grunt.event.on('watch', function(action, filepath, target) {
if (target === 'upload') grunt.config('rsync.dev.options.src', filepath);
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-rsync');
grunt.registerTask('default', ['rsync:dev']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment