1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 01:30:01 +01:00

fix js task, switch to env Babel preset

This commit is contained in:
Matthias Kretschmann 2017-09-09 14:36:29 +02:00
parent a0d6b38a4e
commit 0656b34e61
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,3 @@
{
"presets": ["es2015"]
}
"presets": ["env"]
}

View File

@ -12,6 +12,10 @@ import yaml from 'js-yaml'
import chalk from 'chalk'
import yargs from 'yargs'
// Required for mixing old and ES6+ js with ugify-js 3
import uglifyjs from 'uglify-es'
import composer from 'gulp-uglify/composer'
// Get all the configs: `pkg` and `site`
import pkg from './package'
@ -21,6 +25,9 @@ const site = yaml.safeLoad(fs.readFileSync('./_config.yml'))
const spawn = require('child_process').spawn
const $ = require('gulp-load-plugins')()
// Custom minify
const minify = composer(uglifyjs, console)
// Handle errors
const onError = error => {
console.log($.util.colors.red('\nYou fucked up:', error.message, 'on line', error.lineNumber, '\n'))
@ -204,7 +211,7 @@ export const criticalCss = done => {
//
// Scripts
//
const js = () =>
export const js = () =>
src([
SRC + '/_assets/js/kremalicious3.js',
'node_modules/picturefill/dist/picturefill.js'
@ -213,7 +220,7 @@ const js = () =>
.pipe($.include({
includePaths: ['node_modules', SRC + '/_assets/js']
})).on('error', onError)
.pipe($.if(isProduction, $.uglify())).on('error', onError)
.pipe($.if(isProduction, minify())).on('error', onError)
.pipe($.if(!isProduction, $.sourcemaps.write()))
.pipe($.if(isProduction, $.header(BANNER, {pkg})))
.pipe($.rename({suffix: '.min'}))

View File

@ -53,7 +53,7 @@
"acorn": "^5.1.2",
"autoprefixer": "^7.1.4",
"babel-core": "^6.26.0",
"babel-preset-es2015": ">=6.24.0",
"babel-preset-env": "^1.6.0",
"browser-sync": "^2.18.13",
"chalk": "^2.1.0",
"concurrent-transform": ">=1.0.0",
@ -82,6 +82,7 @@
"gulp-uglify": ">=1.2.0",
"js-yaml": "^3.9.1",
"request": ">=2.81.0",
"uglify-es": "^3.0.28",
"xo": "^0.18.2",
"yargs": "^8.0.2"
},