YegerChill
@YegerChill
Front-End developer

Unexpected token gulp?

Сразу скажу я новичок в этом деле
У меня ошибка при запуске gulp, мне выдаёт ошибку
gulpfile.js:44
function browserSync(params) {
^^^^^^^^

SyntaxError: Unexpected token 'function'
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at requireOrImport (C:\Users\yegor\AppData\Roaming\npm\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11)
at execute (C:\Users\yegor\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:37:3)
at Liftoff.handleArguments (C:\Users\yegor\AppData\Roaming\npm\node_modules\gulp-cli\index.js:211:24)

Вот мой gulpfile:
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 + '/components/_*.html'],
		css: source_folder + '/scss/style.scss',
		js: [source_folder + '/js/**/*.js', '!' + source_folder + '/js/**/_*.js'],
		img: [source_folder + '/img/**/*.{jpg,pnp,svg,gif,ico,webp}', '!' + source_folder + '/img/soc-icons/*.svg'],
		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'),
	babel = require('gulp-babel'),
	browsersync = require('browser-sync').create(), 
	fileinclude = require('gulp-file-include'),
	del = require('del'), 
	scss = require('gulp-sass')(require('sass')), 
	autoprefixer = require('gulp-autoprefixer'), 
	cleancss = require('gulp-clean-css'), 
	rename = require('gulp-rename'), 
	uglify = require('gulp-uglify-es').default,
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 css() {
	return src(path.src.css)
		.pipe(
			scss({
				outputStyle: 'expanded'
			})
		)
		.pipe(
			autoprefixer({
				overrideBrowserList: ['last 5 version'],
				cascade: true
			})
		)
		.pipe(dest(path.build.css))
		.pipe(cleancss({compatibility: 'ie8'}))
		.pipe(rename({suffix: '.min'}))
		.pipe(dest(path.build.css))
		.pipe(browsersync.stream())
}

function js() {
	return src(path.src.js)
		.pipe(fileinclude())
		.pipe(babel({
			presets: ['babel/preset-env']
		}))
		.pipe(dest(path.build.js))
		.pipe(uglify())
		.pipe(rename({suffix: '.min'}))
		.pipe(dest(path.build.js))
		.pipe(browsersync.stream())
}

function images() {
	return src(path.src.img)
		.pipe(dest(path.build.img))
		.pipe(browsersync.stream())
}

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

function clean(params) {
	return del(path.clean);
}

let build = gulp.series(clean, gulp.parallel(html, css, js, images));
let watch = gulp.parallel(build, watchFiles, browserSync);

exports.html = html;
exports.js = js;
exports.css = scss;
exports.images = images;
exports.build = build;
exports.watch = watch;
exports.default = watch;
  • Вопрос задан
  • 947 просмотров
Решения вопроса 1
delphinpro
@delphinpro Куратор тега Gulp.js
frontend developer
Здесь должна быть точка-с-запятой.

60ec12a289e0d100488653.png
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы