const { src, dest, watch, parallel} = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const concat = require('gulp-concat');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const browserSync = require('browser-sync').create();
function browsersync() {
browserSync.init({
server:{
baseDir: 'app/'
}
})
}
function styles() {
return src('scss/style.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(concat('style.mis.css'))
.pipe(autoprefixer({
overrideBrowserslist: ['last 10 version'],
grid: true
}))
.pipe(dest('app/css'))
.pipe(browserSync.stream())
}
function scripts() {
return src([
'node_modules/jquery/dist/jquery.js',
'app/js/main.js'
])
.pipe(concat('main.min.js'))
.pipe(uglify())
.pipe(dest('app/js'))
.pipe(browserSync.stream())
};
function watching() {
watch(['scss/**/*.scss'],styles);
watch(['app/js/**/*.js', '!app/js/main.min.js'], scripts);
watch(['app/**/*.html']).on('cheange', browserSync.reload);
}
exports.styles = styles;
exports.scripts = scripts;
exports.browsersync = browsersync;
exports.watching = watching;
exports.default = parallel(styles, scripts, browsersync, watching)