N
N
nartovbogdan2018-04-09 01:50:50
JavaScript
nartovbogdan, 2018-04-09 01:50:50

How to setup gulp uglify properly?

How to write a task to minify all scripts separately?
If by default I write

gulp.task('javascript', function(){ 
   return gulp.src([ 'app/pre-js/**/*.js' ])
        .pipe(uglify()) 
        .pipe(gulp.dest('app/js'));
});

then all files are compressed into one whole. How to make all files from compressed separately from each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Pavlov, 2018-04-09
@Ifelseapps

Haven't worked with gulp for 1000 years. Perhaps an example of my old config will help you.
When I needed to transpile scss to css and put the result next to the source, I did this:

gulp.task('styles', function ()
{
    return gulp.src(path.join(paths.templatePath, '*.scss'))
  .pipe(sass(sassConfig).on('error', sass.logError))
  .pipe(postcss(postProcessors))
  .pipe(gulp.dest(function (file)
  {
      return file.base;
  }));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question