jellyfin-web/gulpfile.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

'use strict';
2020-02-27 11:11:35 -07:00
const { src, dest, series, parallel } = require('gulp');
const del = require('del');
const babel = require('gulp-babel');
2020-02-27 11:11:35 -07:00
const terser = require('gulp-terser');
const cssnano = require('gulp-cssnano');
const htmlmin = require('gulp-htmlmin');
const imagemin = require('gulp-imagemin');
2020-02-27 11:11:35 -07:00
const sourcemaps = require('gulp-sourcemaps');
// Clean assets
function clean() {
return del(['dist/']);
2020-02-27 11:11:35 -07:00
}
function javascript() {
return src('src/**/*.js', {base: './src/'})
2020-02-27 11:11:35 -07:00
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(terser({
keep_fnames: true,
mangle: false
}))
.pipe(sourcemaps.write('.'))
.pipe(dest('dist/'));
2020-02-27 11:11:35 -07:00
}
function css() {
return src('src/**/*.css', {base: './src/'})
2020-02-27 11:11:35 -07:00
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(cssnano())
.pipe(sourcemaps.write('.'))
.pipe(dest('dist/'));
2020-02-27 11:11:35 -07:00
}
function html() {
return src('src/**/*.html', {base: './src/'})
2020-02-27 11:11:35 -07:00
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(dest('dist/'));
2020-02-27 11:11:35 -07:00
}
function images() {
return src(['src/**/*.png', 'src/**/*.jpg', 'src/**/*.gif', 'src/**/*.svg'], {base: './src/'})
.pipe(imagemin())
.pipe(dest('dist/'))
}
function copy() {
return src(['src/**/*.json', 'src/**/*.ico'], {base: './src/'})
.pipe(dest('dist/'))
}
exports.default = series(clean, parallel(javascript, css, html, images, copy))