silvrgit/gulpfile.js
2017-09-06 08:43:51 +01:00

83 lines
3.3 KiB
JavaScript

const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const cssnano = require('gulp-cssnano');
const jshint = require('gulp-jshint');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const concat = require('gulp-concat');
const cache = require('gulp-cache');
const htmlmin = require('gulp-htmlmin');
const htmlreplace = require('gulp-html-replace');
const stripDebug = require('gulp-strip-debug');
const scss = require('gulp-scss');
const sass = require('gulp-sass');
const googleWebFonts = require('gulp-google-webfonts');
const babel = require('gulp-babel');
const filePath = {
'build_dir': 'live'
};
const dest = 'app/live';
const fontOptions = { };
gulp.task('appJS', function() {
return gulp.src(['app/js/modules/events.js', 'app/js/modules/bitcoin.js', 'app/js/modules/fx.js', 'app/js/modules/train.js', 'app/js/modules/weather.js', 'app/js/modules/password.js', 'app/app.js'])
.pipe(stripDebug())
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(babel({ 'presets': ['es2015'] }))
.pipe(concat('app.js'))
.pipe(uglify({ 'mangle': true, 'compress': { 'sequences': true, // Join consecutive statemets with the “comma operator”
'properties': true, // Optimize property access: a["foo"] → a.foo
'dead_code': true, // Discard unreachable code
'drop_debugger': true, // Discard “debugger” statements
'unsafe': false, // Some unsafe optimizations (see below)
'conditionals': true, // Optimize if-s and conditional expressions
'comparisons': true, // Optimize comparisons
'evaluate': true, // Evaluate constant expressions
'booleans': true, // Optimize boolean expressions
'loops': true, // Optimize loops
'unused': true, // Drop unused variables/functions
'hoist_funs': true, // Hoist function declarations
'hoist_vars': true, // Hoist variable declarations
'if_return': true, // Optimize if-s followed by return/continue
'join_vars': true, // Join var declarations
'cascade': true, // Try to cascade `right` into `left` in sequences
'side_effects': true, // Drop side-effect-free statements
'warnings': true, // Warn about potentially dangerous optimizations/code
'global_defs': {} // global definitions
} }))
.pipe(gulp.dest(`${dest }/js`));
});
gulp.task('customMUI', function() {
return gulp.src(['app/css/custom.scss'])
.pipe(sass({ 'outputStyle': 'compressed' }).on('error', sass.logError))
// .pipe(cssnano())
.pipe(rename('mui.custom.css'))
.pipe(gulp.dest(`${dest }/css`));
});
gulp.task('vendor', function() {
return gulp.src([
'bower_components/zepto/zepto.min.js',
'bower_components/ejs/ejs.min.js',
'bower_components/underscore/underscore-min.js',
'bower_components/backbone/backbone-min.js'
])
.pipe(concat('vendor.js'))
.pipe(uglify({ 'mangle': false }))
.pipe(gulp.dest(`${dest }/js`));
});
gulp.task('fonts', function() {
return gulp.src('./fonts.list')
.pipe(googleWebFonts(fontOptions))
.pipe(gulp.dest(`${dest }/fonts`))
;
});
gulp.task('default', ['appJS', 'vendor', 'customMUI', 'fonts']);