Answer the question
In order to leave comments, you need to log in
Why doesn't the code run?
After I added a small form to the html, this error appeared.
gulp
/home/coda/Documents/gulp-test/gulpfile.js:33
fileinclude = require("gulp-file-include"),
^
SyntaxError: Identifier 'fileinclude' has already been declared
at Object.compileFunction (node:vm: 352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js ( node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader: 822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at requireOrImport (/usr/local/lib/node_modules/gulp/ node_modules/gulp-cli/lib/shared/require-or-import.js:19:11)
at execute (/usr/local/lib/node_modules/gulp/node_modules/gulp-cli/lib/versioned/^4.0.0 /index.js:37:3)
here is the code itself
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", "!" + 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:
let { src, dest } = require('gulp'),
gulp = require('gulp'),
browsersync = require("browser-sync").create(),
fileinclude = require("gulp-file-include") ,
del = require("del"),
scss = require("gulp-sass");
function browserSync(params) {
browsersync.init({
server:{
baseDir: "./" + project_folder + "/"
},
port:3000,
notify:false
})
}
function html() {
return src(path.src. css)
.pipe(dest(path.build.css))
.pipe(browsersync.
.pipe(
scss({
outputStyle: "expanded"
})
)
.pipe(dest(path.build.css))
.pipe(browsersync.stream())
}
function watchFiles(params) {
gulp.watch([path.watch .html], html);
}
function clean(params) {
return del(path.clean);
}
let build = gulp.series(clean, gulp.parallel(css, html));
let watch = gulp.parallel(build, watchFiles, browserSync);
exports.css = css;
exports.html = html;
exports.build = build;
exports.watch = watch;
exports.default = watch;
Answer the question
In order to leave comments, you need to log in
You declared the fileinclude variable twice
SyntaxError: Identifier 'fileinclude' has already been declared
const fileinclude = require('gulp-file-include');
let { src, dest } = require('gulp'),
gulp = require('gulp'),
browsersync = require("browser-sync").create(),
fileinclude = require("gulp-file-include"),
del = require("del"),
scss = require("gulp-sass");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question