ba1kal

Статус
  • Активный

Последние сообщения ba1kal

  • JavaScriptСборка Gulp • 1 августа 2021 г. 23:56

    Почему в браузере выдаёт ошибку Cannot GET / ? let fileinclude = require('gulp-file-include'); let project_folder = "dist"; let source_folder = "src"; let path = { build: { html: project_folder + "/", css: project_folder + "/css/", js: project_folder + "/js/", ...

    Почему в браузере выдаёт ошибку Cannot GET / ?

    let fileinclude = require('gulp-file-include');

    let project_folder = "dist";
    let source_folder = "src";

    let path = {
    build: {
    html: project_folder + "/",
    css: project_folder + "/css/",
    js: project_folder + "/js/",
    img: project_folder + "/img/",
    fonts: project_folder + "/fonts/",
    },
    src: {
    html: source_folder + "/.html",
    css: source_folder + "/scss/style.scss",
    js: source_folder + "/js/script.js",
    img: source_folder + "/img//
    .{jpg,png,svg,gif,ico,webp}",
    fonts: source_folder + "/fonts/.ttf",
    },
    watch: {
    html: source_folder + "//
    .html",
    css: source_folder + "/scss//.scss",
    js: source_folder + "/js/
    /.js",
    img: source_folder + "/img/*/.{jpg,png,svg,gif,ico,webp}",
    },
    clean: "./" + project_folder + "/"
    }

    let { src, dest } = require('gulp'),
    gulp = require('gulp'),
    browsersync = require("browser-sync").create();
    fileinclude = require("gulp-file-include");

    function browserSync(params) {
    browsersync.init({
    server: {
    baseDir: "./" + project_folder + "/"
    },
    port: 3000,
    notify: false
    })
    }

    function html() {
    return src(path.src.html)
    .pipe(fileinclude())
    .pipe(dest(path.build.html))
    .pipe(browsersync.stream())
    }

    function watchFiles(params) {
    gulp.watch([path.watch.html], html);
    }

    let build = gulp.series(html);
    let watch = gulp.parallel(build, watchFiles, browserSync);

    exports.html = html;
    exports.build = build;
    exports.watch = watch;
    exports.default = watch;