mirror of
https://gitlab.silvrtree.co.uk/martind2000/mdot_server.git
synced 2025-01-10 21:05:08 +00:00
145 lines
4.8 KiB
JavaScript
145 lines
4.8 KiB
JavaScript
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');
|
|
var del = require('del');
|
|
var htmlreplace = require('gulp-html-replace');
|
|
var stripDebug = require('gulp-strip-debug');
|
|
|
|
|
|
var filePath = {
|
|
build_dir: './dist'
|
|
};
|
|
|
|
var fontOptions = { };
|
|
|
|
|
|
gulp.task('appJS', function() {
|
|
return gulp.src(['app/js/mdot.js'])
|
|
.pipe(stripDebug())
|
|
.pipe(jshint('.jshintrc'))
|
|
.pipe(jshint.reporter('default'))
|
|
.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(gulp.dest('dist/js'));
|
|
});
|
|
|
|
gulp.task('vendor', function() {
|
|
return gulp.src(['src/bower_modules/mui/packages/cdn/js/mui.min.js',
|
|
'src/bower_modules/jquery/dist/jquery.min.js',
|
|
'src/bower_modules/base64/base64.min.js',
|
|
'src/bower_modules/underscore/underscore-min.js',
|
|
'src/bower_modules/backbone/backbone-min.js',
|
|
'src/bower_modules/sugarjs-date/sugar-date.min.js',
|
|
'src/bower_modules/notification-js/build/notification.min.js',
|
|
'src/bower_modules/amstock3/amcharts/amcharts.js',
|
|
'src/bower_modules/amstock3/amcharts/serial.js',
|
|
'src/bower_modules/amstock3/amcharts/amstock.js'
|
|
])
|
|
.pipe(concat('vendor.js'))
|
|
.pipe(uglify({mangle: false}))
|
|
.pipe(gulp.dest('dist/js'));
|
|
});
|
|
|
|
|
|
|
|
gulp.task('styles', function() {
|
|
return gulp.src(['src/bower_modules/mui/packages/cdn/css/mui.min.css','app/css/test.css','app/css/style.css','src/bower_modules/notification-js/build/notification.min.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(gulp.dest('dist/css'));
|
|
});
|
|
|
|
|
|
gulp.task('index', function() {
|
|
|
|
return gulp.src(['app/index.html'])
|
|
.pipe(htmlreplace({
|
|
mui: 'css/custom.css',
|
|
css: 'css/app.css',
|
|
js: 'js/app.js',
|
|
vendor: 'libs/vendor.js'
|
|
|
|
}))
|
|
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true}))
|
|
|
|
.pipe(gulp.dest('dist/'));
|
|
});
|
|
|
|
|
|
gulp.task('partials', function() {
|
|
|
|
gulp.src(['app/fav/**/*']).pipe(gulp.dest('dist/fav'));
|
|
gulp.src(['app/lib/images/**/*']).pipe(gulp.dest('dist/amcharts/images'));
|
|
// 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/**/*']).pipe(gulp.dest('dist/gfx'));
|
|
});
|
|
|
|
gulp.task('copy', function() {
|
|
return gulp.src(['app/**/*'])
|
|
.pipe(gulp.dest('dist'));
|
|
});
|
|
|
|
gulp.task('buildJS', function() {
|
|
gulp.start('appJS','vendor');
|
|
});
|
|
|
|
gulp.task('clean', function() {
|
|
return del(['dist']);
|
|
});
|
|
|
|
|
|
gulp.task('normal', ['clean'], function() {
|
|
'use strict';
|
|
gulp.start('copy', 'sloc','watch');
|
|
});
|
|
|
|
gulp.task('default', ['clean'], function() {
|
|
gulp.start('buildJS','styles','index','partials');
|
|
});
|
|
|
|
gulp.task('watch',function() {
|
|
gulp.watch('app/**/*',['copy']);
|
|
|
|
});
|
|
|
|
gulp.task('MUIWatcher', function() {
|
|
'use strict';
|
|
gulp.start('customMUI','watchMUI');
|
|
});
|
|
|
|
gulp.task('watchMUI',function() {
|
|
gulp.watch('app/css/custom.scss',['customMUI']);
|
|
|
|
});
|