Skip to content

Commit

Permalink
fixed gulp watch
Browse files Browse the repository at this point in the history
  • Loading branch information
nauvalazhar committed Feb 24, 2019
1 parent a57d117 commit 28516de
Show file tree
Hide file tree
Showing 84 changed files with 135 additions and 111 deletions.
2 changes: 1 addition & 1 deletion assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* You can write your JS code here, DO NOT touch the default style file
* because it will make it harder for you to update.
*
*
*/

"use strict";
12 changes: 6 additions & 6 deletions assets/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $(function() {
}, now_layout_class = null;

var sidebar_sticky = function() {
if($("body").hasClass('layout-2')) {
if($("body").hasClass('layout-2')) {
$("body.layout-2 #sidebar-wrapper").stick_in_parent({
parent: $('body')
});
Expand Down Expand Up @@ -256,7 +256,7 @@ $(function() {
nav_second.find('.sidebar-brand').remove();
nav_second.removeAttr('class');
nav_second.addClass(nav_second_classes);

let main_sidebar = $(".navbar-secondary");
main_sidebar.find('.sidebar-wrapper').addClass('container').removeClass('sidebar-wrapper');
main_sidebar.find('.sidebar-menu').addClass('navbar-nav').removeClass('sidebar-menu');
Expand Down Expand Up @@ -328,15 +328,15 @@ $(function() {
});
});

if($(".chat-content").length) {
if($(".chat-content").length) {
$(".chat-content").niceScroll({
cursoropacitymin: .3,
cursoropacitymax: .8,
});
$('.chat-content').getNiceScroll(0).doScrollTop($('.chat-content').height());
}

if(jQuery().summernote) {
if(jQuery().summernote) {
$(".summernote").summernote({
dialogsInBody: true,
minHeight: 250,
Expand Down Expand Up @@ -440,7 +440,7 @@ $(function() {
backgroundImage: 'url("'+ me.data('image') +'")'
});
});
if(jQuery().Chocolat) {
if(jQuery().Chocolat) {
$(".gallery").Chocolat({
className: 'gallery',
imageSelector: '.gallery-item',
Expand Down Expand Up @@ -527,7 +527,7 @@ $(function() {
width: $(this).data('width')
});
});

// Height attribute
$('[data-height]').each(function() {
$(this).css({
Expand Down
70 changes: 47 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ var cssDir = './assets/css',
jsDir = './assets/js',
htmlDir = './sources/pages',
sassDir = './sources/scss',
imgDir = './assets/img/*';
imgDir = './assets/img';

/**
* Helpers
*/

function _compile_html(path, log=true, ret=false) {
function _compile_html(path, onEnd, log=true, ret=false) {
if(log)
_log('[HTML] Compiling:' + path, 'GREEN');

let compile_html = src(path, { base: htmlDir })
.pipe(plumber())
.pipe(nunjucks.compile({
version: '2.3.0'
version: '2.3.0',
site_name: 'Stisla'
},
/**
* Nunjucks options
Expand All @@ -60,16 +61,21 @@ function _compile_html(path, log=true, ret=false) {
}
}
}))
.pipe(dest('pages'))
.pipe(plumber.stop());
.on('error', console.error.bind(console))
.on('end', () => {
if(onEnd)
onEnd.call(this);

if(ret) return compile_html;
if(ret) return compile_html;

if(log)
_log('[HTML] Finished', 'GREEN');
if(log)
_log('[HTML] Finished', 'GREEN');
})
.pipe(dest('pages'))
.pipe(plumber.stop());
}

function _compile_scss(path, log=true, ret=false) {
function _compile_scss(path, onEnd, log=true, ret=false) {
if(log)
_log('[SCSS] Compiling:' + path, 'GREEN');

Expand All @@ -79,18 +85,22 @@ function _compile_scss(path, log=true, ret=false) {
errorLogToConsole: true
}))
.on('error', console.error.bind(console))
.on('end', () => {
if(onEnd)
onEnd.call(this);

if(ret) return compile_html;

if(log)
_log('[SCSS] Finished', 'GREEN');
})
.pipe(rename({
dirname: '',
extname: '.css'
}))
.pipe(postcss([autoprefixer()]))
.pipe(dest(cssDir))
.pipe(plumber.stop());

if(ret) return compile_scss;

if(log)
_log('[SCSS] Finished', 'GREEN');
}

function _log(str, clr) {
Expand Down Expand Up @@ -132,7 +142,7 @@ function minify(){
}

function image() {
return src(imgDir)
return src(imgDir + '/**/*.*')
.pipe(plumber())
.pipe(imagemin([
imageminMozjpeg({quality: 80})
Expand All @@ -142,11 +152,11 @@ function image() {
}

function compile_scss() {
return _compile_scss(sassDir + '/*.scss', false, true);
return _compile_scss(sassDir + '/*.scss', null, false, true);
}

function compile_html() {
return _compile_html(htmlDir + '/*.html', false, true);
return _compile_html(htmlDir + '/*.html', null, false, true);
}

function watching() {
Expand All @@ -159,22 +169,36 @@ function watching() {
baseDir: "./"
},
startPath: 'pages/index.html',
port: 1000
port: 8080
});

/**
* Watch ${htmlDir}
*/
watch([htmlDir + '/*.html', sassDir + '/*.scss']).on('change', (file) => {
watch([
htmlDir + '/**/*.html',
sassDir + '/*.scss',
jsDir + '/**/*.js',
cssDir + '/**/*.css',
imgDir + '/**/*.*',
]).on('change', (file) => {
if(file.indexOf('.scss') > -1) {
_compile_scss(file);
_compile_scss(file, () => {
return browserSync.reload();
});
}

if(file.indexOf('.html') > -1) {
_compile_html(file);
if(file.indexOf('layouts') > -1 && file.indexOf('.html') > -1) {
_compile_html(htmlDir + '/*.html', () => {
return browserSync.reload();
});
}else if(file.indexOf('.html') > -1) {
_compile_html(file, () => {
return browserSync.reload();
});
}

browserSync.reload();
return browserSync.reload();
});
}

Expand Down
2 changes: 1 addition & 1 deletion pages/auth-forgot-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Forgot Password &mdash; </title>
<title>Forgot Password &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/auth-login.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Login &mdash; </title>
<title>Login &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/auth-register.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Register &mdash; </title>
<title>Register &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/auth-reset-password.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Reset Password &mdash; </title>
<title>Reset Password &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/blank.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Blank Page &mdash; </title>
<title>Blank Page &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Alert &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Alert &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-badge.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Badge &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Badge &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-breadcrumb.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Breadcrumb &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Breadcrumb &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Buttons &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Buttons &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Card &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Card &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Carousel &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Carousel &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-collapse.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Collapse &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Collapse &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-dropdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Dropdown &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Dropdown &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Form &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Form &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-list-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; List Group &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; List Group &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-media-object.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Media Object &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Media Object &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Modal &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Modal &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Nav &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Nav &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Navbar &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Navbar &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Pagination &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Pagination &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion pages/bootstrap-popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no" name="viewport">
<title>Bootstrap Components &amp;rsaquo; Popover &mdash; </title>
<title>Bootstrap Components &amp;rsaquo; Popover &mdash; Stisla</title>

<!-- General CSS Files -->
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
Expand Down
Loading

0 comments on commit 28516de

Please sign in to comment.