Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirHumeniuk committed Sep 6, 2017
1 parent 7c40187 commit f43c1a7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 29 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015"],
"retainLines": true
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/node_modules
/.tmp
.DS_Store
/dist
4 changes: 4 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<meta name="msapplication-TileColor" content="#2F3BA2">
<!-- Color the status bar on mobile devices-->
<meta name="theme-color" content="#2F3BA2">
<!-- Styles-->
<!-- build:css styles/main.min.css-->
<link href="/styles/main.min.css" rel="stylesheet">
<!-- endbuild-->
</head>
<body>
<!-- Site content goes here-->
Expand Down
5 changes: 5 additions & 0 deletions app/pug/core/head.pug
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ head

// Color the status bar on mobile devices
meta(name='theme-color', content='#2F3BA2')

// Styles
// build:css styles/main.min.css
link(href='/styles/main.min.css', rel='stylesheet')
// endbuild
20 changes: 9 additions & 11 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
(function() {
'use strict';

var isLocalhost = Boolean(window.location.hostname === 'localhost' ||
((() => {
const isLocalhost = Boolean(window.location.hostname === 'localhost' ||
window.location.hostname === '[::1]' ||
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
Expand All @@ -11,15 +9,15 @@
if ('serviceWorker' in navigator &&
(window.location.protocol === 'https:' || isLocalhost)) {
navigator.serviceWorker.register('service-worker.js')
.then(function(registration) {
registration.onupdatefound = function() {
.then(registration => {
registration.onupdatefound = () => {
if (navigator.serviceWorker.controller) {
var installingWorker = registration.installing;
const installingWorker = registration.installing;

installingWorker.onstatechange = function() {
installingWorker.onstatechange = () => {
switch (installingWorker.state) {
case 'installed':
break;
break;

case 'redundant':
throw new Error('The installing ' +
Expand All @@ -31,10 +29,10 @@
};
}
};
}).catch(function(e) {
}).catch(e => {
console.error('Error during service worker registration:', e);
});
}

// JavaScript goes here
})();
}))();
7 changes: 7 additions & 0 deletions app/styles/test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
color: red;
}

h1 {
font-size: 3px;
}
37 changes: 19 additions & 18 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import path from 'path';
import gulp from 'gulp';
import del from 'del';
Expand Down Expand Up @@ -33,6 +31,8 @@ gulp.task('images', () =>
gulp.task('copy', () =>
gulp.src([
'fonts/*',
'!app/pug',
'!app/libs',
'app/*',
'!app/*.html',
'node_modules/apache-server-configs/dist/.htaccess'
Expand Down Expand Up @@ -67,6 +67,7 @@ gulp.task('styles', () => {
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/styles'))
.pipe($.concat('main.min.css'))

.pipe($.if('*.css', $.cssnano()))
.pipe($.size({title: 'styles'}))
.pipe($.sourcemaps.write('./'))
Expand All @@ -78,26 +79,26 @@ gulp.task('scripts', () =>
gulp.src([
'./app/scripts/main.js'
])
.pipe($.newer('.tmp/scripts'))
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('.tmp/scripts'))
.pipe($.concat('main.min.js'))
.pipe($.uglify({preserveComments: 'some'}))

.pipe($.size({title: 'scripts'}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/scripts'))
.pipe(gulp.dest('.tmp/scripts'))
.pipe($.newer('.tmp/scripts/**/*.js'))
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.sourcemaps.write())
.pipe(gulp.dest('.tmp/scripts'))
.pipe($.concat('main.min.js'))
.pipe($.uglify({preserveComments: 'some'}))

.pipe($.size({title: 'scripts'}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/scripts'))
.pipe(gulp.dest('.tmp/scripts'))
);

gulp.task('pug', () =>
gulp.src('app/pug/*.pug')
.pipe($.pug({
pretty: '\t'
}))
.pipe(gulp.dest('app/'))
.pipe($.pug({
pretty: '\t'
}))
.pipe(gulp.dest('app/'))
);

gulp.task('html', () => {
Expand Down

0 comments on commit f43c1a7

Please sign in to comment.