const gulp = require('gulp'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
browsersync = require('browser-sync').create();
function style() {
return gulp.src('./source/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(autoprefixer({cascade: true}))
.pipe(gulp.dest('./build/css/'))
.pipe(browsersync.stream());
};
function watch() {
browsersync.init({
server: {
baseDir: './build/'
},
port: 3000,
notify: false
});
gulp.watch('./source/sass/**/*.scss', style);
gulp.watch('./source/*.html').on('change', gulp.series(browsersync.reload));
gulp.watch('./source/js/**/*.js').on('change', gulp.series(browsersync.reload));
};
exports.style = style;
exports.watch = watch;
{
"name": "Project",
"version": "1.0.0",
"description": "MyNewProject",
"main": "gulpfile.js",
"dependencies": {},
"devDependencies": {
"browser-sync": "^2.26.3",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^6.1.0",
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.6.5",
"gulp-watch": "^5.0.1",
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
},
"browserslist": [
"since 2015",
"IE 10"
],
"author": "Fedya",
"license": "ISC"
}
function style() {
return gulp.src('./source/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({cascade: true}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./build/css/'))
.pipe(browsersync.stream());
};