const gulp = require('gulp')


exports.watch = function watch() {
  const config = require('./config').default
  const browserSync = require('browser-sync')

  gulp.watch(`${config.paths.src.images }/**/*.{jpg,jpeg,ico,png,gif,svg}`, gulp.series('images', done => { // https://github.com/BrowserSync/browser-sync/issues/1065#issuecomment-215516517
    browserSync.reload()
    done()
  }))

  const webpack = require('webpack')
  const webpackConfig = require('../webpack.config')
  const compiler = webpack(webpackConfig)
  compiler.watch({}, (err, stats) => {
    if (err) {
      console.error(err)
      return
    }

    console.log(stats.toString({ colors: true }))
    browserSync.reload()
  })

  gulp.watch(`${config.paths.src.styles }/**/*.scss`, gulp.series('styles:dev'))

  gulp.watch([
    `${config.paths.src.base }/**/*.pug`,
    `${config.paths.src.base }/**/*.yml`,
  ], gulp.series('html:dev', 'html:sitemap', done => {
    browserSync.reload()
    done()
  }))

  gulp.watch([
    `${config.paths.src.base }/robots.txt`,
    `${config.paths.src.base }/.htaccess`,
    `${config.paths.src.base }/humans.txt`,
  ], gulp.series('copy:base', done => {
    browserSync.reload()
    done()
  }))

  gulp.watch(`${config.paths.src.base }/assets/libraries/**/*`, gulp.series('copy:libraries', done => {
    browserSync.reload()
    done()
  }))

  gulp.watch(`${config.paths.src.fonts }/**/*`, gulp.series('copy:fonts', done => {
    browserSync.reload()
    done()
  }))

  const modRewrite = require('connect-modrewrite')
  const compression = require('compression')
  browserSync({
    ghostMode: {
      clicks: false,
      scroll: false,
      forms: false,
    },
    server: {
      baseDir: config.paths.dist.base,
      middleware: [
        modRewrite([
          '^.([^\\.]+)$ /$1.html [L]', // Remove .html from URL (as in the .htaccess)
        ]),
        compression(), // Enable gzip compression
      ],
    },
    https: true,
    online: false,
  })
}

@@ -980,38 +980,32 @@
 )%0A%0A  gulp.watch(
-%5B%0A    
 %60$%7Bconfig.paths.
@@ -1012,416 +1012,51 @@
 src.
-base %7D/robots.txt%60,%0A    %60$%7Bconfig.paths.src.base %7D/.htaccess%60,%0A    %60$%7Bconfig.paths.src.base %7D/humans.txt%60,%0A  %5D, gulp.series('copy:base', done =%3E %7B%0A    browserSync.reload()%0A    done()%0A  %7D))%0A%0A  gulp.watch(%60$%7Bconfig.paths.src.base %7D/assets/libraries/**/*%60, gulp.series('copy:libraries', done =%3E %7B%0A    browserSync.reload()%0A    done()%0A  %7D))%0A%0A  gulp.watch(%60$%7Bconfig.paths.src.fonts %7D/**/*%60, gulp.series('copy:fonts
+copyToDist %7D/**/*%60, gulp.series('copyToDist
 ', d

Update watch.js