mqtt_server/gulpfile.js

110 lines
3.9 KiB
JavaScript
Raw Normal View History

2016-11-23 19:19:03 +00:00
/**
* Created by martin on 11/23/16.
*/
2016-06-22 15:07:56 +00:00
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer');
var cssnano = require('gulp-cssnano');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var notify = require('gulp-notify');
var cache = require('gulp-cache');
var livereload = require('gulp-livereload');
var htmlmin = require('gulp-htmlmin');
var inject = require('gulp-inject');
2016-11-23 19:19:03 +00:00
var update = require('gulp-banner');
var atob = require('atob');
2016-06-22 15:07:56 +00:00
var del = require('del');
var htmlreplace = require('gulp-html-replace');
var stripDebug = require('gulp-strip-debug');
2016-11-23 19:19:03 +00:00
var babel = require('gulp-babel');
2016-06-22 15:07:56 +00:00
var filePath = {
2016-11-23 19:19:03 +00:00
build_dir: './dist'
};
var fontOptions = { };
gulp.task('appJS', function() {
2017-01-07 22:33:43 +00:00
return gulp.src(['app/js/websocket.js','app/js/tempSocket.js','app/js/modules/clock.js','app/js/modules/temp.js','app/js/modules/graph.js','app/js/app.js'])
2016-11-23 19:19:03 +00:00
.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: false, // 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(update(atob('LyogPT09PT09PQ0KDQpEZXZlbG9wZWQgYnkgTWFydGluIERvbm5lbGx5IG1hcnRpbmQyMDAwe2F0fWdtYWlsLmNvbQ0KDQo9PT09PT09ICovDQoNCg==')))
.pipe(gulp.dest('dist/js'));
});
2016-06-22 15:07:56 +00:00
gulp.task('vendor', function() {
2016-11-23 19:19:03 +00:00
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/underscore/underscore-min.js',
'bower_components/backbone/backbone-min.js',
'app/libs/sugar-full.min.js'
])
2016-06-22 15:07:56 +00:00
.pipe(concat('vendor.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('styles', function() {
2016-11-23 19:19:03 +00:00
return gulp.src([
'app/css/custom.css',
'app/css/today.css'])
2016-06-22 15:07:56 +00:00
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(cssnano())
.pipe(concat('app.css'))
.pipe(gulp.dest('dist/css'));
});
gulp.task('index', function() {
return gulp.src(['app/index.html'])
.pipe(htmlreplace({
2016-11-23 19:19:03 +00:00
mui: 'css/custom.css',
css: 'css/app.css',
js: 'js/app.js',
vendor: 'js/vendor.js'
}))
2016-06-22 15:07:56 +00:00
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true}))
2016-11-23 19:19:03 +00:00
2016-06-22 15:07:56 +00:00
.pipe(gulp.dest('dist/'));
});
2016-11-23 19:19:03 +00:00
gulp.task('buildJS', function() {
gulp.start('appJS','vendor');
2016-06-22 15:07:56 +00:00
});
gulp.task('clean', function() {
2016-11-23 19:19:03 +00:00
return del(['dist']);
});
2016-06-22 15:07:56 +00:00
gulp.task('default', ['clean'], function() {
2016-11-23 19:19:03 +00:00
gulp.start('buildJS','styles','index');
});