Gulp task do release

I am new to Gulp. I am trying to create an issue in a folder dist. The structure of the project is as follows:

_untitled/
 └── app/
     └── img/
     └── jade/
     └── script/
     └── style/
     └── vendor/
     └── 404.html
     └── index.html
 └── node_modules/
 └── gulpfile.js
 └── package.json

Here is my gulpfile.js:

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();

//-------------------- jade
gulp.task('jade', function () {
    return gulp.src('app/jade/*.jade')
    .pipe($.jade({
        pretty: true
    }))
    .on('error', console.log)
    .pipe(gulp.dest('app'))
    .pipe($.size());
});

//-------------------- style
gulp.task('style', function () {
    return gulp.src('app/style/sass/main.scss')
    .pipe($.rubySass({
        style: 'expanded',
        'sourcemap=none': true,
        noCache: true
    }))
    .pipe($.autoprefixer({
            browsers: ['last 2 versions']
        }))
    .pipe(gulp.dest('app/style'))
    .pipe($.size());
});

//-------------------- script
gulp.task('script', function () {
    return gulp.src('app/script/**/*.js')
    .pipe($.jshint())
    .pipe($.jshint.reporter(require('jshint-stylish')))
    .pipe($.size());
});

//-------------------- htmlDist
gulp.task('htmlDist', function () {
    return gulp.src('app/**/*.html')
    .pipe(gulp.dest('dist'))
    .pipe($.size());
});

//-------------------- styleDist
gulp.task('styleDist', function () {
    return gulp.src('app/style/**/*.css')
    .pipe($.concat('main.css'))
    .pipe($.csso())
    .pipe(gulp.dest('dist/style'))
    .pipe($.size());
});

//-------------------- scriptDist
gulp.task('scriptDist', function () {
    return gulp.src('app/script/**/*.js')
    .pipe($.uglify())
    .pipe(gulp.dest('dist/script'))
    .pipe($.size());
});

//-------------------- cleanDist
gulp.task('cleanDist', function () {
    var del = require('del');
    return del('dist');
});

//-------------------- build
gulp.task('build', ['jade', 'style', 'script']);

//-------------------- buildDist
gulp.task('buildDist', ['htmlDist', 'styleDist', 'scriptDist']);

//-------------------- release
gulp.task('release', ['cleanDist', 'build', 'buildDist']);

At the same time, when I type gulp release, I have ok dist, except that it is index.htmlempty and 0 KB. And then, when I try again to do it gulp release(the second time, with an existing folder dist), I only have a 404.htmlfile in the folder distand an error with the following output:

gulp release
[02:36:14] Using gulpfile D:\Coding\_untitled\gulpfile.js
[02:36:14] Starting 'cleanDist'...
[02:36:14] Finished 'cleanDist' after 52 ms
[02:36:14] Starting 'jade'...
[02:36:15] Starting 'style'...
[02:36:16] Starting 'script'...
[02:36:17] Starting 'htmlDist'...
[02:36:17] Starting 'styleDist'...
[02:36:17] Starting 'scriptDist'...
[02:36:17] all files 38 B
[02:36:17] Finished 'script' after 1.19 s
[02:36:17] all files 432 B
[02:36:17] Finished 'jade' after 2.88 s

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: ENOENT, chmod 'D:\Coding\_untitled\dist\script\main.js'

, gulp release ( ), dist . , ( index.html), dist , . , , dist, . gulp buildDist (index.html ).

, , . .

+4
2

gulp, , . , jade, style script htmlDist, styleDist scriptDist.

run-sequence, , .

var runSequence = require('run-sequence');

gulp.task('build', function(callback) {
  runSequence('cleanDist', 'build', 'buildDist', callback);
});
+5

Gulp , ,

:

var gulp = require('gulp');

// takes in a callback so the engine knows when it'll be done
gulp.task('one', function(cb) {
    // do stuff -- async or otherwise
    cb(err); // if err is not null and not undefined, the run will stop, and note that it failed
});

// identifies a dependent task must be complete before this one begins
gulp.task('two', ['one'], function() {
    // task 'one' is done now
});

gulp.task('default', ['one', 'two']);
0

All Articles