Commit 2872e322 authored by Nikolay Gromov's avatar Nikolay Gromov

browser sync and notify

parent ac69da8d
......@@ -17,6 +17,8 @@ const path = require('path');
const cheerio = require('gulp-cheerio');
const fileinclude = require('gulp-file-include');
const newer = require('gulp-newer');
const notify = require('gulp-notify');
const browserSync = require('browser-sync').create();
// Запуск `NODE_ENV=production gulp [задача]` приведет к сборке без sourcemaps
const isDev = !process.env.NODE_ENV || process.env.NODE_ENV == 'dev';
......@@ -28,6 +30,12 @@ gulp.task('less', function () {
.pipe(gulpIf(isDev, sourcemaps.init()))
.pipe(debug({title: "LESS:"}))
.pipe(less())
.on('error', notify.onError(function(err){
return {
title: 'Styles error',
message: err.message
}
}))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
......@@ -124,7 +132,18 @@ gulp.task('watch', function () {
gulp.watch('src/img/*.{jpg,jpeg,gif,png,svg}', gulp.series('img'));
});
// Локальный сервер
gulp.task('serve', function () {
gulp.series('build');
browserSync.init({
server: 'build'
});
browserSync.watch('build/**/*.*').on('change', browserSync.reload);
});
// Задача по умолчанию
gulp.task('default', gulp.series('build', 'watch'));
gulp.task('default',
gulp.series('build', gulp.parallel('watch', 'serve'))
);
......@@ -9,6 +9,7 @@
"license": "MIT",
"repository": "nicothin/start-project--gulp",
"devDependencies": {
"browser-sync": "^2.11.1",
"del": "^2.2.0",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-autoprefixer": "^3.1.0",
......@@ -20,6 +21,7 @@
"gulp-imagemin": "^2.4.0",
"gulp-less": "^3.0.5",
"gulp-newer": "^1.1.0",
"gulp-notify": "^2.2.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.6.0",
"gulp-svgmin": "^1.2.1",
......
......@@ -20,6 +20,8 @@
<h1>Заголовок h1</h1>
<img src="img/TEMP_DavidBlaine.jpg" alt="">
@@include('_include/page_footer.html')
@@include('_include/page_bottom.html')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment