Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gulp pipe(gulp.dest()) does not create any results

i am currently learning about gulp.js. as i saw the tutorial and documentation of gulp.js, this code:

gulp.src('js/*.js')
.pipe(uglify())
.pipe(gulp.dest('minjs'));

makes the uglified javascript file with create new directory named 'minjs'. of course, i installed gulp-uglity with --dev-save option. there is no error message on the console so i don't know what is the problem. i tried gulp with "sudo", but still not working.

so i went to the root directory and searched all filesystem but there is no file named 'minjs' so i guess it just not working. why this is happening? anyone knows this problem, it would be nice why this is happening.

whole source code:

var gulp = require('gulp');
var uglify = require('gulp-uglify');

gulp.task('default', function() {
    console.log('mifying scripts...');

    gulp.src('js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('minjs'));
});
like image 572
modernator Avatar asked Jan 02 '16 10:01

modernator


People also ask

What is gulp DEST?

dest() Creates a stream for writing Vinyl objects to the file system.

What is pipe in gulp?

The flow of data will be automatically managed so that the destination Writable stream is not overwhelmed by a faster Readable stream. So in Gulp you can chain multiple tasks together using the pipe() method. Gulp makes use of streams.

What is gulp watch command?

The watch() API connects globs to tasks using a file system watcher. It watches for changes to files that match the globs and executes the task when a change occurs. If the task doesn't signal Async Completion, it will never be run a second time.


1 Answers

Finally I resolved the question like this:

It was a directory mistake so the gulp task hasn't matched any files; then it couldn't create the dest directory (because no files in output).

const paths = {
  dest: {
    lib: './lib',
    esm: './esm',
    dist: './dist',
  },
  styles: 'src/components/**/*.less',
  scripts: ['src/components/**/*.{ts,tsx}', '!src/components/**/demo/*.{ts,tsx}'],
};

At first my scripts was ['components/**/*.{ts,tsx}', '!components/**/demo/*.{ts,tsx}']

And that hasn't matched any files.

like image 147
Caper Avatar answered Oct 03 '22 08:10

Caper