silvrgit/gulpfile.js
2017-04-20 13:42:55 +01:00

83 lines
3.3 KiB
JavaScript

const gulp = require('gulp');
let autoprefixer = require('gulp-autoprefixer');
let cssnano = require('gulp-cssnano');
let jshint = require('gulp-jshint');
let uglify = require('gulp-uglify');
let rename = require('gulp-rename');
let concat = require('gulp-concat');
let cache = require('gulp-cache');
let htmlmin = require('gulp-htmlmin');
let htmlreplace = require('gulp-html-replace');
let stripDebug = require('gulp-strip-debug');
let scss = require('gulp-scss');
let sass = require('gulp-sass');
let googleWebFonts = require('gulp-google-webfonts');
let babel = require('gulp-babel');
let filePath = {
build_dir: 'live'
};
let dest = 'app/live';
let 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']);