K
K
krll-k2016-01-19 04:09:31
JavaScript
krll-k, 2016-01-19 04:09:31

What do gulp.src, gulp.dest, and gulp.watch expect as input?

1) I have a Gulpfile:

spoiler
'use strict';

var gulp = require('gulp'),
    less = require('gulp-less'),
    livereload = require('gulp-livereload'),
    http = require('http'),
    st = require('st');

gulp.task('less', function() {
  gulp.src('app/styles/*.less')
    .pipe(less())
    .pipe(gulp.dest('dist/styles'))
    .pipe(livereload());
});

gulp.task('watch', ['server'], function() {
  livereload.listen({ basePath: 'dist' });
  gulp.watch('less/*.less', ['less']);
});

gulp.task('server', function(done) {
  http.createServer(
    st({ path: __dirname + '/dist', index: 'index.html', cache: false })
  ).listen(8080, done);
});

2) I want to change in gulp.src('app/styles/*.less') path.
3) What is this path about?
4) If I write gulp.src('./*.css') there, will it work on windows?
My project file structure is such that there are no folders, but only index.html, style.css and app.js

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krll-k, 2016-01-19
@krll-k

https://github.com/gulpjs/gulp/blob/master/docs/API.md
To understand you have to delve into nodejs itself, this is not a browser for you ;-)

var gulp = require('gulp');

gulp.task('default', function() {
  gulp.src("./*.css")
  	.pipe(gulp.dest('./'));
  gulp.watch('./*.js', function(event) {
  	console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question