Добрый день.
Вот мой конфиг.
"use strict";
const gulp = require("gulp");
const ftp = require("vinyl-ftp");
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");
var log = require("fancy-log");
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/"))
.on("end", function () {
log("webpack");
});
});
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/"))
.on("end", function () {
log("scss");
});
});
gulp.task("deploy", function () {
console.log("getConn function is running!");
var conn = ftp.create({
host: "ftp14.hostland.ru",
user: "host1670806_baseecommerce",
password: "sdkjfdf",
parallel: 10,
log: log.info("deploy"),
});
const globs = [
"front-page.php",
"assets/**/**",
"import/**/**",
"inc/**/**",
"shortcodes/**/**",
"template-parts/**/**",
"woocommerce/**/**",
"404.php",
"archive.php",
"footer.php",
"functions.php",
"gulpfile.js",
"header.php",
"index.php",
"page-cart.php",
"single.php",
"page-privacy.php",
];
// using base = '.' will transfer everything to /public_html correctly
// turn off buffering in gulp.src for best performance
return gulp
.src(globs, { base: ".", buffer: false })
.pipe(conn.newer("/wp-content/themes/base-ecommerce")) // only upload newer files
.pipe(conn.dest("/wp-content/themes/base-ecommerce"))
.on("end", function () {
log("deploy");
});
});
gulp.task("watch", function () {
gulp
.watch("**/*.php")
.on("change", gulp.series("deploy", browserSync.reload));
gulp.watch("assets/scss/**/*.scss").on("change", gulp.series("scss"));
gulp
.watch("assets/css/**/*.css")
.on("change", gulp.series("deploy", browserSync.reload));
gulp.watch("assets/js/src/**/*.js").on("change", gulp.series("webpack"));
gulp
.watch("assets/js/dist/**/*.*")
.on("change", gulp.series("deploy", browserSync.reload));
gulp
.watch("assets/fonts/**/*.*")
.on("change", gulp.series("deploy", browserSync.reload));
gulp
.watch("assets/i/**/**")
.on("change", gulp.series("deploy", browserSync.reload));
gulp
.watch("assets/libs/**/*.*")
.on("change", gulp.series("deploy", browserSync.reload));
});
gulp.task("browser-sync", function () {
browserSync.init({
proxy: {
target: "http://wc-base-ecommerce.host1670806.hostland.pro/",
ws: true,
},
notify: true,
});
});
gulp.task(
"default",
gulp.series("webpack", "scss", gulp.parallel("watch", "browser-sync"))
);
А вот логи при загрузки
https://paste.ubuntu.com/p/XwG2mXj8vr/
Аж 7 секунд деплоя.
Я изменил стили только в одном scss файле, а он загружает и другие, почему?
Заранее благодарен.