nurl/gulpfile.js

107 lines
3.6 KiB
JavaScript
Raw Normal View History

2017-08-05 22:28:59 +00:00
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 inject = require('gulp-inject');
const del = require('del');
const htmlreplace = require('gulp-html-replace');
const stripDebug = require('gulp-strip-debug');
const babel = require('gulp-babel');
var fontOptions = { };
gulp.task('appJS', function() {
return gulp.src(['public/javascripts/shorten.js'])
.pipe(stripDebug())
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
2017-09-05 14:53:07 +00:00
.pipe(babel({ presets: ['es2015'] }))
2017-08-05 22:28:59 +00:00
.pipe(concat('nurl.js'))
2017-09-05 14:53:07 +00:00
.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
} }))
2017-08-05 22:28:59 +00:00
// .pipe(update(atob('LyogPT09PT09PQ0KDQpEZXZlbG9wZWQgYnkgTWFydGluIERvbm5lbGx5IG1hcnRpbmQyMDAwe2F0fWdtYWlsLmNvbQ0KDQo9PT09PT09ICovDQoNCg==')))
.pipe(gulp.dest('live/js'));
});
gulp.task('vendor', function() {
2017-09-05 14:53:07 +00:00
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/mui/packages/cdn/js/mui.min.js'
])
2017-08-05 22:28:59 +00:00
.pipe(concat('vendor.js'))
2017-09-05 14:53:07 +00:00
.pipe(uglify({ mangle: false }))
2017-08-05 22:28:59 +00:00
.pipe(gulp.dest('live/js'));
2017-09-05 14:53:07 +00:00
});
2017-08-05 22:28:59 +00:00
gulp.task('styles', function() {
2017-09-05 14:53:07 +00:00
return gulp.src(['public/css/roboto.css', 'bower_components/mui/packages/cdn/css/mui.min.css', 'public/css/styles.css'])
2017-08-05 22:28:59 +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('live/css'));
2017-09-05 14:53:07 +00:00
});
2017-08-05 22:28:59 +00:00
gulp.task('migrate', function() {
2017-08-07 21:21:36 +00:00
return gulp.src(['fav/favicon-16x16.png'])
.pipe(gulp.dest('live'));
2017-08-05 22:28:59 +00:00
});
gulp.task('index', function() {
2017-09-05 14:53:07 +00:00
return gulp.src(['views/index.html'])
2017-08-05 22:28:59 +00:00
.pipe(htmlreplace({
mui: 'css/mui.min.css',
css: 'css/app.css',
js: 'js/nurl.js',
vendor: 'js/vendor.js'
}))
2017-09-05 14:53:07 +00:00
.pipe(htmlmin({ removeComments: true, collapseWhitespace: true, keepClosingSlash: true }))
2017-08-05 22:28:59 +00:00
.pipe(gulp.dest('dist/'));
2017-09-05 14:53:07 +00:00
});
2017-08-05 22:28:59 +00:00
gulp.task('clean', function() {
return del(['live']);
});
gulp.task('buildJS', function() {
2017-09-05 14:53:07 +00:00
gulp.start('appJS', 'vendor');
2017-08-05 22:28:59 +00:00
});
gulp.task('default', ['clean'], function() {
//gulp.start('buildJS','styles','index');
2017-09-05 14:53:07 +00:00
gulp.start('buildJS', 'styles', 'index', 'migrate');
2017-08-05 22:28:59 +00:00
});