Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install gulp without npm on a shared hosting?

On my shared hosting I would like to have access to gulp (gulp watch) to compile my LESS assets into CSS. To install gulp I must have npm installed as well.

Unfortunately hosting administrator refused to install npm. Is there any other way to get gulp working on my server?

My gulpfile.js is presented below:

var gulp = require('gulp'),
    connect = require('gulp-connect'),
    less = require('gulp-less');

gulp.task('webserver', function() {
    connect.server({
        livereload: true
    });
});

gulp.task('less', function() {
    gulp.src('assets/less/app.less')
        .pipe(less())
        .on('error', console.log.bind(console))
        .pipe(gulp.dest('css'))
        .pipe(connect.reload());
});

gulp.task('fonts', function() {
    gulp.src([
        'bower_components/bootstrap/fonts/*',
        'bower_components/fontawesome/fonts/*'
    ])
    .pipe(gulp.dest('fonts'));
});

gulp.task('watch', function() {
    gulp.watch('assets/less/*.less', ['less']);
});

gulp.task('default', ['webserver', 'less', 'fonts', 'watch']);

Probably I would need to do the same with bower. Making long story short - I just developed my small tiny project on my OS X MAMP localhost where I did all the stuff in terminal (bower search etc. gulp watch etc.)

In terms of my hosting I also have access to the shell via ssh -l login host.

Thank you for any hints or even a clear answer that it's impossible.

like image 392
Matt Komarnicki Avatar asked Dec 24 '22 17:12

Matt Komarnicki


2 Answers

You can not use gulp without node, but gulp is devel tool.

I think you not need gulp on production server. On production server usually you give files processed with gulp, but no gulp directly.

like image 106
milanlempera Avatar answered Dec 27 '22 21:12

milanlempera


gulp.task('webserver', function() {
    connect.server({
        livereload: true
    });
});

This is a gulp task never needed on production.

gulp.task('less', function() {
    gulp.src('assets/less/app.less')
        .pipe(less())
        .on('error', console.log.bind(console))
        .pipe(gulp.dest('css'))
        .pipe(connect.reload());
});
// ...
gulp.task('watch', function() {
    gulp.watch('assets/less/*.less', ['less']);
});

These are gulp task never needed on production. You should be putting the compiled CSS files onto the server, perhaps only the compiled CSS and not the .less files.

gulp.task('fonts', function() {
    gulp.src([
        'bower_components/bootstrap/fonts/*',
        'bower_components/fontawesome/fonts/*'
    ])
    .pipe(gulp.dest('fonts'));
});

This is a gulp task never needed on production. You can simply put those files on the server in the compiled destination.

In short, just put your compiled files on prod. Gulp is a build tool. Push the build to production, not the source code.

like image 33
J-Dizzle Avatar answered Dec 27 '22 19:12

J-Dizzle