mqtt_server/gulpfile.js.old
2016-11-23 19:19:03 +00:00

118 lines
3.7 KiB
JavaScript

'use strict';
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 jsmin = require('gulp-jsmin');
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');
var del = require('del');
var htmlreplace = require('gulp-html-replace');
var googleWebFonts = require('gulp-google-webfonts');
var stripDebug = require('gulp-strip-debug');
var size = require('gulp-size');
var debug = require('gulp-debug');
var filePath = {
build_dir: './dist'
};
gulp.task('scripts', function() {
return gulp.src(['app/js/sowebsocket.js','app/js/colours.js','app/js/appv2.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.pipe(concat('app.js'))
// .pipe(stripDebug())
.pipe(jsmin())
.pipe(size({title: 'Scripts'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('vendor', function() {
return gulp.src(['bower_components/jquery/dist/jquery.min.js',
'bower_components/mui/packages/cdn/js/mui.min.js',
'bower_components/chroma-js/chroma.min.js',
'bower_components/sugar/release/sugar-full.min.js',
'app/lib/skycons.js',
'app/lib/microevent.js'])
.pipe(concat('vendor.js'))
.pipe(uglify({mangle: false}))
.pipe(size({title: 'Vendor'}))
.pipe(gulp.dest('dist/js'));
});
gulp.task('styles', function() {
return gulp.src(['app/css/mui.custom.css','app/css/material-icons.css','app/css/app.css'])
.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(size({title: 'Styles'}))
.pipe(gulp.dest('dist/css'));
});
gulp.task('partials', function() {
// Gulp.src(['app/partials/**/*']).pipe(gulp.dest('dist/partials'));
// gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs'));
// gulp.src(['app/libs/microevent.js']).pipe(gulp.dest('dist/libs'));
gulp.src(['app/fav/**/*']).pipe(size({title: 'Partials'})).pipe(gulp.dest('dist/fav'));
gulp.src(['app/gfx/censis_logo_white.png']).pipe(gulp.dest('dist/gfx'));
});
gulp.task('migrate', function() {
return gulp.src(['dist/**/*'])
.pipe(debug({title: 'migrate:'}))
.pipe(size({title: 'Migrate'}))
.pipe(gulp.dest('/Users/martin/newdev/SODashApp/www'));
});
gulp.task('index', function() {
var sources = gulp.src(['js/apps.js', 'css/app.css'], {read: false});
return gulp.src(['app/index.html'])
.pipe(htmlreplace({
css: 'css/app.css',
js: 'js/app.js',
vendor: 'js/vendor.js',
fonts: 'fonts/fonts.css'
}))
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true}))
.pipe(size({title: 'Index'}))
.pipe(gulp.dest('dist/'));
});
var options = { };
gulp.task('fonts', function() {
return gulp.src('./fonts.list')
.pipe(googleWebFonts(options))
.pipe(size({title: 'Fonts'}))
.pipe(gulp.dest('dist/fonts'))
;
});
gulp.task('clean', function() {
return del(['dist']);
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'vendor', 'fonts', 'partials', 'index');
});
gulp.task('Cordova', ['clean'], function() {
gulp.start('styles', 'scripts', 'vendor', 'fonts', 'index');
});