minify html, add steps for fonts, upgrade packages

This commit is contained in:
Jakub Sokołowski 2018-08-11 10:09:51 -04:00
parent a2329ed075
commit b8dd17a701
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 174 additions and 19 deletions

View File

@ -13,31 +13,40 @@ var sourcemaps = require('gulp-sourcemaps')
var del = require('del')
var gutil = require('gulp-util')
var rename = require('gulp-rename')
var uglify = require('gulp-uglify')
var htmlmin = require('gulp-htmlmin')
var imagemin = require('gulp-imagemin')
gulp.task('js', function () {
return gulp.src('src/**/*.js', {read: false})
return gulp.src('src/js/**/*.js', {read: false})
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(tap(function (file) {
gutil.log('bundling ' + file.path)
//gutil.log('bundling ' + file.path)
file.contents = browserify(file.path, {debug: true}).bundle()
}))
.pipe(streamify(babel({ presets: ['es2015', 'es2017'] })))
.pipe(buffer())
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.stream())
})
gulp.task('fonts', function() {
return gulp.src(['src/fonts**/*'])
.pipe(gulp.dest('dist'))
})
gulp.task('html', function() {
return gulp.src(['src/**/*.html'])
.pipe(htmlmin({collapseWhitespace: true, minifyJS: true}))
.pipe(rename(p => p.dirname = p.dirname.slice(5)))
.pipe(gulp.dest('dist'))
})
gulp.task('sass', function() {
gulp.task('css', function() {
return gulp.src("src/scss/main.scss")
.pipe(sass())
.on('error', gutil.log)
@ -46,7 +55,7 @@ gulp.task('sass', function() {
.pipe(browserSync.stream())
})
gulp.task('imagemin', function() {
gulp.task('images', function() {
gulp.src('src/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'))
@ -57,13 +66,13 @@ gulp.task('clean', function() {
})
gulp.task('develop', ['build'], function() {
browserSync.init({server: "./"})
browserSync.init({server: "./dist"})
gulp.watch("src/scss/*.scss", ['sass'])
gulp.watch("src/scss/*.scss", ['css'])
gulp.watch("src/js/*.js", ['js'])
gulp.watch("src/img/**/*", ['imagemin'])
gulp.watch("./*.html").on('change', browserSync.reload)
gulp.watch("src/img/**/*", ['images'])
gulp.watch("./*.html", ['html']).on('change', browserSync.reload)
})
gulp.task('build', ['clean', 'sass', 'imagemin', 'js'])
gulp.task('build', ['clean', 'css', 'images', 'fonts', 'js', 'html'])
gulp.task('default', ['develop'])

163
package-lock.json generated
View File

@ -166,7 +166,6 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz",
"integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=",
"dev": true,
"requires": {
"ansi-wrap": "0.1.0"
}
@ -184,7 +183,6 @@
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz",
"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
"dev": true,
"requires": {
"ansi-wrap": "0.1.0"
}
@ -202,8 +200,7 @@
"ansi-wrap": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz",
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
"dev": true
"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768="
},
"anymatch": {
"version": "1.3.2",
@ -277,8 +274,7 @@
"arr-flatten": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==",
"dev": true
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg=="
},
"arr-union": {
"version": "3.1.0",
@ -1720,6 +1716,14 @@
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"dev": true
},
"bufferstreams": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/bufferstreams/-/bufferstreams-1.1.3.tgz",
"integrity": "sha512-HaJnVuslRF4g2kSDeyl++AaVizoitCpL9PglzCYwy0uHHyvWerfvEb8jWmYbF1z4kiVFolGomnxSGl+GUQp2jg==",
"requires": {
"readable-stream": "2.3.3"
}
},
"build-url": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/build-url/-/build-url-1.1.2.tgz",
@ -1780,6 +1784,15 @@
"integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
"dev": true
},
"camel-case": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-3.0.0.tgz",
"integrity": "sha1-yjw2iKTpzzpM2nd9xNy8cTJJz3M=",
"requires": {
"no-case": "2.3.2",
"upper-case": "1.1.3"
}
},
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
@ -1933,7 +1946,6 @@
"version": "4.1.9",
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.1.9.tgz",
"integrity": "sha1-Nc7ornaHpJuYA09w3gDE7dOCYwE=",
"dev": true,
"requires": {
"source-map": "0.5.7"
}
@ -5021,6 +5033,64 @@
"through2": "2.0.3"
}
},
"gulp-htmlmin": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/gulp-htmlmin/-/gulp-htmlmin-4.0.0.tgz",
"integrity": "sha512-9FX2d4QbSm+4WuXughjZ6GJn4jx0C4BmyK2e+AS6567NPAetNfB+hv2ZL/88AacdC+8OS+TzeIjfKRXPSAgOYw==",
"requires": {
"bufferstreams": "1.1.3",
"html-minifier": "3.5.19",
"plugin-error": "0.1.2",
"readable-stream": "2.3.3",
"tryit": "1.0.3"
},
"dependencies": {
"arr-diff": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"requires": {
"arr-flatten": "1.1.0",
"array-slice": "0.2.3"
}
},
"arr-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0="
},
"array-slice": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU="
},
"extend-shallow": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"requires": {
"kind-of": "1.1.0"
}
},
"kind-of": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ="
},
"plugin-error": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"requires": {
"ansi-cyan": "0.1.1",
"ansi-red": "0.1.1",
"arr-diff": "1.1.0",
"arr-union": "2.1.0",
"extend-shallow": "1.1.4"
}
}
}
},
"gulp-if": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/gulp-if/-/gulp-if-2.0.2.tgz",
@ -5696,6 +5766,11 @@
"sntp": "1.0.9"
}
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0="
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
@ -5738,6 +5813,41 @@
"integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==",
"dev": true
},
"html-minifier": {
"version": "3.5.19",
"resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.19.tgz",
"integrity": "sha512-Qr2JC9nsjK8oCrEmuB430ZIA8YWbF3D5LSjywD75FTuXmeqacwHgIM8wp3vHYzzPbklSjp53RdmDuzR4ub2HzA==",
"requires": {
"camel-case": "3.0.0",
"clean-css": "4.1.9",
"commander": "2.16.0",
"he": "1.1.1",
"param-case": "2.1.1",
"relateurl": "0.2.7",
"uglify-js": "3.4.7"
},
"dependencies": {
"commander": {
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz",
"integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew=="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"uglify-js": {
"version": "3.4.7",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.7.tgz",
"integrity": "sha512-J0M2i1mQA+ze3EdN9SBi751DNdAXmeFLfJrd/MDIkRc3G3Gbb9OPVSx7GIQvVwfWxQARcYV2DTxIkMyDAk3o9Q==",
"requires": {
"commander": "2.16.0",
"source-map": "0.6.1"
}
}
}
},
"htmlescape": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
@ -7112,6 +7222,11 @@
"signal-exit": "3.0.2"
}
},
"lower-case": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz",
"integrity": "sha1-miyr0bno4K6ZOkv31YdcOcQujqw="
},
"lowercase-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz",
@ -7530,6 +7645,14 @@
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
"dev": true
},
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
"integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==",
"requires": {
"lower-case": "1.1.4"
}
},
"node-gyp": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz",
@ -8008,6 +8131,14 @@
"integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
"dev": true
},
"param-case": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/param-case/-/param-case-2.1.1.tgz",
"integrity": "sha1-35T9jPZTHs915r75oIWPvHK+Ikc=",
"requires": {
"no-case": "2.3.2"
}
},
"parents": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
@ -8753,6 +8884,11 @@
"jsesc": "0.5.0"
}
},
"relateurl": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz",
"integrity": "sha1-VNvzd+UUQKypCkzSdGANP/LYiKk="
},
"remove-bom-buffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz",
@ -9502,8 +9638,7 @@
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
},
"source-map-resolve": {
"version": "0.5.2",
@ -10247,6 +10382,11 @@
"integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
"dev": true
},
"tryit": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz",
"integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics="
},
"tty-browserify": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
@ -10467,6 +10607,11 @@
"integrity": "sha1-uYTwh3/AqJwsdzzB73tbIytbBv4=",
"dev": true
},
"upper-case": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz",
"integrity": "sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg="
},
"urix": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz",

View File

@ -36,6 +36,7 @@
"d3-interpolate": "^1.2.0",
"d3-scale": "^1.0.7",
"gulp-file-include": "^1.0.0",
"gulp-htmlmin": "^4.0.0",
"ip": "^1.1.5",
"js-cookie": "^2.1.4",
"lodash.assign": "^4.2.0",