Answer the question
In order to leave comments, you need to log in
Wrong file showing in browsersync plugin?
I started building gulp, connected Browsersync and file-include, files are connected but for some reason Error not found is displayed
const 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();
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;
PS C:\User\Admin\Desktop\html&css\ПРИМЕР> gulp
[22:03:00] Using gulpfile ~\Desktop\html&css\sample\gulpfile.js
[22:03:00] Starting 'default'...
[22:03:00] Starting 'watchFiles'...
[22:03:00] Starting 'browserSync'...
[22:03:00] Starting 'html'...
[Browsersync] 2 files changed (header.html, index.html)
[22:03:00] Finished 'html' after 108 ms
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:3002
External: http://26.88.229.176:3002
--------------------------------------
UI: http://localhost:3003
UI External: http://localhost:3003
--------------------------------------
[Browsersync] Serving files from: ./
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question