W
W
WebforSelf2021-05-28 10:00:33
SSH
WebforSelf, 2021-05-28 10:00:33

How to run gulp 3 via SSH?

I installed node.js and gulp in the directory with the site, in the same place in the root
of gulpfile.js , now how to run gulp?

(docker) [email protected]:~/public_html [0] $ gulp --version
CLI version: 2.3.0
Local version: 3.9.1

The utility is available through the docker environment. You can access it with the following command.
ssh localhost -p222

connected via putty , entered the docker environment

Now there is gulpfile.js in the root

var gulp = require('gulp'),
    autoprefixer = require('gulp-autoprefixer'),
    sass = require('gulp-sass'),
    sourcemaps = require('gulp-sourcemaps'),
    bs = require('browser-sync'),
    svgstore = require('gulp-svgstore'),
    svgmin = require('gulp-svgmin'),
    rename = require('gulp-rename'),
    inject = require('gulp-inject'),
    watch = require('gulp-watch'),
    path = 'design/furniture_v1/';

gulp.task('sprite', function () {
  var iconPath = path + 'images/icon/',
      svgs = gulp
        .src(iconPath + 'sprite/*.svg')
        .pipe(svgmin())
        .pipe(rename({prefix: 'icon-'}))
        .pipe(svgstore({ 
          inlineSvg: true 
        }));
  function fileContents (filePath, file) {
    return file.contents.toString();
  }
  return gulp
    .src(iconPath + '_svg.tpl')
    .pipe(inject(svgs, { 
      transform: fileContents 
    }))
    .pipe(gulp.dest(path+'html'));
});

/*задача для эмуляции сервера*/
gulp.task('bs', function(){
  bs({
    proxy: 'furniture-shop.loc',
    port: 433,
    notify: false
  });
});

/*задача для компиляции css*/
gulp.task('sass', function(){
  return gulp.src(path+'scss/**/*.scss')
    .pipe(sourcemaps.init()) // нициализируем sourcemaps
    .pipe(sass({
      outputStyle: 'compressed' // минифицируем компилируемый css
    }).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['> 5%', 'last 2 versions', 'ie >= 10'] // добавляем вендорные префиксы
    }))
    .pipe(sourcemaps.write('.')) //сохраняем sourcemap файлы в ту же директорию, что и css
    .pipe(gulp.dest(path+'css/'))
    .pipe(bs.reload({stream: true}));
});

/*Задача на отслеживание изменений*/
gulp.task('watch', ['sass', 'bs'], function(){
  gulp.watch(path+'scss/**/*.scss', ['sass']);
  gulp.watch(path+'js/**/*.js').on('change', bs.reload);
  gulp.watch(path+'html/*.tpl').on('change', bs.reload);
  gulp.watch(path+'lang/*.php').on('change', bs.reload);
  gulp.watch('../compiled/**/*.php').on('change', bs.reload);
});

gulp.task('default', ['bs', 'sass', 'watch']);


How can I run it to track changes and collect everything?

Do I understand correctly that I can work with scss via FTP and it will track changes on the fly and update the compiled file?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question