I created a project using the Yeoman 'generator-webapp'. This includes a Grunt task named 'connect', to run the project on a server. Currently it is running on my localhost. Can anyone explain to me how I should configure this to run on a different server?
I have a server provided by my university that I can use. Let's say it's called xyz.abc.com with username myUsername and password myPassword.
The Grunt task is defined like this:
// The actual grunt server settings
connect: {
options: {
port: 9000,
open: true,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function(connect) {
return [
connect.static('.tmp'),
connect().use('/bower_components', connect.static('./bower_components')),
connect.static(config.app)
];
}
}
},
test: {
options: {
open: false,
port: 9001,
middleware: function(connect) {
return [
connect.static('.tmp'),
connect.static('test'),
connect().use('/bower_components', connect.static('./bower_components')),
connect.static(config.app)
];
}
}
},
dist: {
options: {
base: '<%= config.dist %>',
livereload: false
}
}
},
If you want to deploy, your app on a distant server with grunt, you can use a similar approch as I did : by adding a new deploy parameter on your yeoman build grunt task or create a new deploy dedicated task using :
For example, I have a build task that compiles/optimize/minify/revision resources where I added a deploy parameter :
grunt.registerTask(
'build',
'Build task, does everything',
function() {
var tasks = [
[...], // custom build tasks
'zipup:buildClient' // end of build generates a zip package
];
if (grunt.option('deploy')) {
tasks.push('sshexec:cleanApacheDir'); // empty remote folder for a fresh new install
tasks.push('sftp:sendZipToApache'); // send zip through SFTP
tasks.push('sshexec:unzipToApache'); // unzip trough SSH command `unzip`
}
grunt.task.run(tasks);
}
);
See modules docs for details
ps: there are tons of other grunt plugins that you could use for that.
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