简体   繁体   中英

gulp not creating `concat` file

I am trying to create all.js file from all .js files in one folder with the help of gulp. But i am not getting all.js file.

Steps i have followed as follows:

  1. Created Gulp.js file as below

File: gulpfile.js

// grab our gulp packages
var gulp  = require('gulp'),
    gutil = require('gulp-util'),
    concat = require('gulp-concat-util');

// create a default task and just log a message
gulp.task('default', function() {
  return gutil.log('Gulp is running!')
});

gulp.task('scripts', function() {
  gulp.src(['./js/*.js'])
    .pipe(concat.scripts('all.js'))
    .pipe(uglify())
    .pipe(gulp.dest('./dist/'))
});
  1. run gulp command.

After running gulp, i am getting message as Gulp is running as mentioned in file. But Js file is not created.

Any help shall be appreciated.

You're not running the task. You need to run the command gulp scripts

Gulp is a task runner. It allows you to specify tasks . The default task is run when you run the gulp command. If you want to run a task other than the default task you must

  1. Run gulp {{taskname}} where {{taskname}} is callback called via gulp.task in your gulpfile or
  2. Call the specified task via the default task.

You haven't done either. So when you run gulp from the command line, all you are running is the default task, which does nothing except call gutil.log and then return.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM