N
N
Nikita Fedorov2019-04-25 23:19:57
gulp.js
Nikita Fedorov, 2019-04-25 23:19:57

Task to update .html/.js on Gulp 4?

There is a structure:
app
---css

  • -main.scss
  • -fonts.scss

---js
  • -main.js

---img
  • -bg.png
  • -1bg.png

---fonts
  • -1.ttf
  • -1.otf

---index.html
dist
---
---
---
How to write a task to transfer .html/.js/fonts/img to dist?
Preferably with watch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Dobrin, 2019-04-26
@NikitaFedorov

For your assembly will go like this watcher:

gulp.task('watch', function(){
  gulp.watch('файлы html', gulp.series('html'));
  gulp.watch('файлы css', gulp.series('css'));
  gulp.watch('файлы js', gulp.series('js'));
  gulp.watch('файлы img', gulp.series('img'));
})

Instead 'файлы [html, css, js&img]'write the path to the files.
And buildersomething like this:
gulp.task('build', 
  gulp.series(
    сюда можно таск очитки dist папки засунуть, т.е. его название, типа 'clean',
    gulp.parallel(
      'html',
      'styles',
      'js',
      'img'
)));

If the task is not needed for cleaning, then you can delete the line with gulp.series, and do not forget to remove all the brackets associated with this method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question