var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
gulp.task('serve', function(done) {
browserSync.init({
server: "src/"
});
gulp.watch("scr/sass/*.sass", gulp.parallel('sass'));
gulp.watch("scr/*.html").on('change', () => {browserSync.reload();
done();
});
done();
});
gulp.task('sass', function(done) {
gulp.src("scr/sass/*.sass")
.pipe(sass())
.pipe(gulp.dest("scr/css"))
.pipe(browserSync.stream());
done();
});
gulp.task('default', gulp.parallel('serve', 'sass'));
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync');
gulp.task('sass', function() {
return gulp.src('src/sass/main.sass')
.pipe(sass({outputStyle: 'expanded'}))
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('html', function() {
return gulp.src('src/*.html')
.pipe(browserSync.reload({stream: true}))
});
// Static server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "src/"
}
});
});
gulp.task ('watch', function() {
gulp.watch('src/sass/**/*.sass', gulp.parallel('sass'))
gulp.watch('src/*.html', gulp.parallel('html'))
});
gulp.task('default', gulp.parallel('browser-sync', 'watch'))
gulp.watch('src/*.html', gulp.parallel('html'))
server: {
baseDir: "src/",
index: 'index.html',
},
watch: true
function gluingJS() {
let jsFile = fs.readdirSync('src/js/dev');
return (
browserify({
entries: jsFile,
basedir: "src/js/dev",
debug: true,
})
.transform(babelify, {
presets: ['@babel/preset-env'],
})
.bundle()
.pipe(source('bundle.min.js'))
.pipe(buffer())//uglify не заводиться без vinyl-buffer
.pipe(sourcemaps.init({
loadMaps: true,
}))
.pipe(uglify())//удалил карты, теперь debug: true бесполезен
.pipe(sourcemaps.write('./sourcemap'))
.pipe(dest('src/js'))
.pipe(bs.reload({stream: true}))
)
}
function gluingJS() {
let jsFile = fs.readdirSync('src/js/dev');
return (
browserify({
entries: jsFile,
basedir: "src/js/dev",
debug: true,
})
.transform(babelify, {
presets: ['@babel/preset-env'],
})
.bundle((err, buffer) => {
let event = new EventEmitter();
if (err) {
event.emit('error',err)
}
else {
let data = minify(buffer.toString(), {}).code;//uglifu-js
fs.createWriteStream('./src/js/bundle.min.js').write(data)
bs.reload()
}
})
)
}