S
S
Sergey Burduzha2021-11-06 08:53:14
gulp.js
Sergey Burduzha, 2021-11-06 08:53:14

Why doesn't gulp work for a site from laradock?

Good afternoon.
There is gulpfile and package.json, I use this assembly to work with sites on wordpress.
Only I use ftp.

"use strict";
const gulp = require("gulp");
const webpack = require("webpack-stream");
const sass = require("gulp-sass");
const autoprefixer = require("gulp-autoprefixer");
const sourcemaps = require("gulp-sourcemaps");
const plumber = require("gulp-plumber");
const wait = require("gulp-wait"),
  notify = require("gulp-notify");
const browserSync = require("browser-sync");
let isDev = true;
let webpackConfig = {
  output: {
    filename: "webpack.js"
  },
  watch: false,
  module: {
    rules: [
      {
        test: /\.m?js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: "babel-loader",
          options: {
            presets: [
              [
                "@babel/preset-env",
                {
                  debug: true,
                  corejs: 3,
                  useBuiltIns: "usage"
                }
              ]
            ]
          }
        }
      }
    ]
  },
  mode: isDev ? "development" : "production",
  devtool: isDev ? "eval-source-map" : "none"
};
gulp.task("webpack", function() {
  return gulp
    .src("assets/js/src/main.js")
    .pipe(webpack(webpackConfig))
    .pipe(gulp.dest("assets/js/dist/"))
    .pipe(browserSync.stream());
});
gulp.task("scss", function() {
  return gulp
    .src("assets/scss/my.scss")
    .pipe(plumber())
    .pipe(sourcemaps.init())
    .pipe(wait(500))
    .pipe(
      sass().on(
        "error",
        notify.onError(function(error) {
          return (
            "An error occurred while compiling sass.\nLook in the console for details.\n" +
            error
          );
        })
      )
    )
    .pipe(
      autoprefixer({
        cascade: false
      })
    )
    .pipe(sourcemaps.write("."))
    .pipe(gulp.dest("assets/css/"))
    .pipe(browserSync.stream());
});
gulp.task("watch", function() {
  browserSync.init({
    proxy: {
      target: "http://oop.local/",
      ws: true
    },
    reloadDelay: 1000,
    notify: true,
    open: false
  });
  gulp.watch("**/*.html").on("change", browserSync.reload);
  gulp.watch("**/*.php").on("change", browserSync.reload);
  gulp.watch("**/*.css").on("change", browserSync.reload);
  gulp.watch("assets/js/dist/webpack.js").on("change", browserSync.reload);
  gulp.watch("assets/js/custom-jquery.js").on("change", browserSync.reload);
  gulp.watch("assets/scss/**/*.scss", gulp.series("scss"));
  gulp.watch("assets/js/src/**/*.js", gulp.series("webpack"));
});
gulp.task("default", gulp.series("webpack", "scss", gulp.parallel("watch")));


Started learning laravel.
And I want to use automatic page reload.

I installed laradock and created a test project oop next to it.

In the project, I transferred gulpfile and package.json, installed dependencies and launched gulp.

There are no errors, but after changing the php file, the browser does not restart.

What's wrong?

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question