Deploying with MM4

Is there some documentation or other information explaining how to deploy (FTP) as in previous versions of middleman?

Normally you would use middleman-deploy (https://github.com/middleman-contrib/middleman-deploy). But when i tried last time there was an error on windows systems.

As a workaround i now use gulp with vinyl-ftp.

In my config.rb i have something like this:

after_build do |builder|
exec(‘gulp deploy’)
end

And my gulpfile.js looks something like this:

var gulp = require(‘gulp’);
var ftp = require(‘vinyl-ftp’);

gulp.task(‘deploy’, function() {
var conn = ftp.create({
host: ‘HOSTNAME’,
user: ‘USERNAME’,
password: ‘PASSWORD’,
parallel: 10
});

var globs = [
‘build/**’
];

conn.clean(globs, ‘build’)

return gulp.src(globs, {base: ‘build’, buffer: false})
.pipe(conn.newer(’/PROJECT_DIRECTORY’)) // only upload newer files
.pipe(conn.dest(’/PROJECT_DIRECTORY’));
});

This by the way has another advantage. middleman-deploy uploads every file, with vinyl-ftp you can only upload newer files or use other options to set what should be uploaded.

I’m not really a fan of gulp as it pulls in tons of extra stuff in my project, but I’ll try vinyl-ftp as suggested.

Can not run so:

after_build do |builder|
exec(‘rsync --whatever need’)
end

Thanks
Silvio

Shure you can, and you should if it is possible. But in my case it was a shard hosting server where the only way to upload files was ftp.
But the prefered way is to use middleman-deploy if you can. I just had problems using middleman-deploy with ftp on windows.

You are right, its not a nice solution, its more like a workaround until middleman-deploy with ftp on windows is working.
In my case i was already using gulp because of gulp-critical https://github.com/addyosmani/critical which is an amazing extension.

With critical i got a 100 score on google pagespeed insights.
https://developers.google.com/speed/pagespeed/insights/?hl=de&url=http%3A%2F%2Fwww.mnm-engineering.com%2F