E
E
Emil Valeev2016-01-21 21:29:11
Pug
Emil Valeev, 2016-01-21 21:29:11

Why does gulp not create or edit files, although in the watch and build console - tasks work fine?

'use strict';

var gulp = require('gulp'),
    watch = require('gulp-watch'),
    jade = require('gulp-jade'),
    stylus = require('gulp-stylus'),
    prefixer = require('gulp-autoprefixer'),
    uglify = require('gulp-uglify'),
    rigger = require('gulp-rigger'),
    cssmin = require('gulp-minify-css');

var path = {
    build: {
        html: 'build/',
        js: 'build/js/',
        css: 'build/css/',
        img: 'build/img/',
        fonts: 'build/fonts/'
    },
    src: {
        jade: 'src/*.jade', 
        js: 'src/js/main.js',
        style: 'src/style/main.styl',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    watch: { 
        jade: 'src/**/*.jade',
        js: 'src/js/**/*.js',
        style: 'src/style/**/*.styl',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    clean: './build'
};

gulp.task('html:build', function() {
 
  gulp.src(path.src.jade)
    .pipe(jade({
      pretty: true
    }))
    .pipe(gulp.dest(path.build.html))
});

gulp.task('js:build', function () {
    gulp.src(path.src.js) 
        .pipe(rigger()) 
        .pipe(uglify()) 
        .pipe(gulp.dest(path.build.js)); 
});

gulp.task('style:build', function () {
  gulp.src(path.src.style)
    .pipe(stylus())
    .pipe(prefixer({ browsers: ['last 25 versions'] }))
    .pipe(gulp.dest(path.build.css));
});

gulp.task('fonts:build', function() {
    gulp.src(path.src.fonts)
        .pipe(gulp.dest(path.build.fonts))
});

gulp.task('build', [
    'html:build',
    'js:build',
    'style:build',
    'fonts:build'
]);

gulp.task('watch', function(){
    watch([path.watch.jade], function(event, cb) {
        gulp.start('html:build');
    });
    watch([path.watch.style], function(event, cb) {
        gulp.start('style:build');
    });
    watch([path.watch.js], function(event, cb) {
        gulp.start('js:build');
    });
    watch([path.watch.fonts], function(event, cb) {
        gulp.start('fonts:build');
    });
});

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

---
[email protected] Z:\home\csssr
$ gulp
[21:20:58] Using gulpfile Z:\home\csssr\gulpfile.js
[21:20:58] Starting 'html:build'.. .
[21:20:58] Finished 'html:build' after 12 ms
[21:20:58] Starting 'js:build'...
[21:20:58] Finished 'js:build' after 5.35 ms
[ 21:20:58] Starting 'style:build'...
[21:20:58] Finished 'style:build' after 5.61 ms
[21:20:58] Starting 'fonts:build'...
[21: 20:58] Finished 'fonts:build' after 1.16 ms
[21:20:58] Starting 'build'...
[21:20:58] Finished 'build' after 15 μs
[21:20:58] Starting ' watch'...
[21:20:58] Finished 'watch' after 15 ms
[21:20:58] Starting 'default'...
[21:20:58] Finished 'default' after 13 μs
===
Solutions from similar questions do not fit

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