65 lines
2.6 KiB
JavaScript
65 lines
2.6 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 = 'live';
|
|
|
|
|
|
let fontOptions = { };
|
|
|
|
gulp.task('appJS', function() {
|
|
return gulp.src(['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: 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(dest + '/js'));
|
|
});
|
|
|
|
gulp.task('vendor', function() {
|
|
return gulp.src([
|
|
'app/libs/zepto.min.js',
|
|
'app/libs/microevent.js',
|
|
'app/libs/ejs.js'
|
|
])
|
|
.pipe(concat('vendor.js'))
|
|
.pipe(uglify({mangle: false}))
|
|
.pipe(gulp.dest(dest + '/js'));
|
|
}); |