F
F
freeman02042016-05-24 00:20:13
JavaScript
freeman0204, 2016-05-24 00:20:13

How to copy needed files via gulp?

Why is my public folder deleted on first launch? After restart everything is ok.
How to write in this line

return gulp.src('frontend/assets/{fonts,images}/**', {since: gulp.lastRun('assets')})
so that not only the fonts, images folders would be copied, but also the index.html file for example?
My settings:
const gulp = require('gulp');
const concatCSS = require('gulp-concat-css');
const debug = require('gulp-debug');
const sourcemaps = require('gulp-sourcemaps');
const gulpIf = require('gulp-if');
const del = require('del');

const isDevelopment = !process.env.NODE_ENV || process.env.NODE_ENV == 'development';

gulp.task('styles', function () {

  return gulp.src('frontend/**/*.css')
    .pipe(concatCSS('all.css'))
    .pipe(gulpIf(isDevelopment, sourcemaps.init()))
    .pipe(gulpIf(isDevelopment, sourcemaps.write()))
    .pipe(gulp.dest('public'));

});

gulp.task('clean', function() {
  return del('public');
});

gulp.task('assets', function() {
  return gulp.src('frontend/assets/{fonts,images}/**', {since: gulp.lastRun('assets')})
    .pipe(gulp.dest('public'));
});

gulp.task('build', gulp.series(
  'clean',
  gulp.parallel('styles', 'assets'))
);

gulp.task('watch', function() {
  gulp.watch('frontend/styles/**/*.*', gulp.series('styles'));
  gulp.watch('frontend/assets/**/*.*', gulp.series('assets'));
});

gulp.task('dev', gulp.series('build', 'watch'));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danila, 2016-05-24
@freeman0204

the folder is deleted because

gulp.task('clean', function() {
  return del('public');
});

write down
return gulp.src(['frontend/assets/{fonts,images}/**', 'frontend/assets/index.html'], {since: gulp.lastRun('assets')})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question