mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-28 07:59:55 +03:00

Merge tags and scripts; now it will be `docker-registry-ui.js` and `docker-registry-ui-static.js` New sort for tags; will use numerical sort when it is possible
122 lines
No EOL
3.3 KiB
JavaScript
122 lines
No EOL
3.3 KiB
JavaScript
'use strict';
|
|
const cleanCSS = require('gulp-clean-css');
|
|
const concat = require('gulp-concat');
|
|
const del = require('del');
|
|
const filter = require('gulp-filter');
|
|
const fs = require('fs');
|
|
const gIf = require('gulp-if');
|
|
const gulp = require('gulp');
|
|
const htmlmin = require('gulp-htmlmin');
|
|
const license = require('gulp-license');
|
|
const riot = require('gulp-riot');
|
|
const uglify = require('uglify-es');
|
|
const minifier = require('gulp-uglify/composer')(uglify);
|
|
const useref = require('gulp-useref');
|
|
const injectVersion = require('gulp-inject-version');
|
|
const merge = require('stream-series');
|
|
|
|
const allTags = 'src/tags/*.tag';
|
|
|
|
const allScripts = [
|
|
'src/scripts/http.js',
|
|
'src/scripts/script.js'
|
|
];
|
|
|
|
const staticTags = [
|
|
'src/tags/catalog.tag',
|
|
'src/tags/app.tag',
|
|
'src/tags/taglist.tag',
|
|
'src/tags/copy-to-clipboard.tag',
|
|
'src/tags/remove-image.tag',
|
|
'src/tags/image-size.tag',
|
|
'src/tags/image-tag.tag'
|
|
];
|
|
|
|
const staticScripts = [
|
|
'src/scripts/http.js',
|
|
'src/scripts/static.js'
|
|
];
|
|
|
|
gulp.task('html', function() {
|
|
var htmlFilter = filter('**/*.html', {restore: true});
|
|
return gulp.src(['src/index.html'])
|
|
.pipe(useref())
|
|
.pipe(gIf(['*.js', '!*.min.js'], minifier())) // FIXME
|
|
.pipe(htmlFilter)
|
|
.pipe(htmlmin({
|
|
removeComments: false,
|
|
collapseWhitespace: true,
|
|
removeRedundantAttributes: true,
|
|
removeEmptyAttributes: true,
|
|
minifyJS: uglify
|
|
}))
|
|
.pipe(htmlFilter.restore)
|
|
.pipe(gulp.dest('dist'));
|
|
});
|
|
|
|
gulp.task('clean', function(done) {
|
|
return del(['dist']);
|
|
});
|
|
|
|
gulp.task('docker-registry-ui-static', ['html'], function() {
|
|
return merge(gulp.src(staticScripts), gulp.src(staticTags).pipe(riot()))
|
|
.pipe(concat('docker-registry-ui-static.js'))
|
|
.pipe(minifier())
|
|
.pipe(license('agpl3', {
|
|
tiny: false,
|
|
project: 'docker-registry-ui',
|
|
year: '2016-2018',
|
|
organization: 'Jones Magloire @Joxit'
|
|
}))
|
|
.pipe(injectVersion())
|
|
.pipe(gulp.dest('dist/scripts'));
|
|
});
|
|
|
|
gulp.task('docker-registry-ui', ['html'], function() {
|
|
return merge(gulp.src(allScripts), gulp.src(allTags).pipe(riot()))
|
|
.pipe(concat('docker-registry-ui.js'))
|
|
.pipe(minifier())
|
|
.pipe(license('agpl3', {
|
|
tiny: false,
|
|
project: 'docker-registry-ui',
|
|
year: '2016-2018',
|
|
organization: 'Jones Magloire @Joxit'
|
|
}))
|
|
.pipe(injectVersion())
|
|
.pipe(gulp.dest('dist/scripts'));
|
|
});
|
|
|
|
gulp.task('vendor', ['html'], function() {
|
|
return gulp.src(['node_modules/riot/riot.min.js', 'node_modules/riot-route/dist/route.min.js', 'node_modules/riot-mui/build/js/riot-mui-min.js'])
|
|
.pipe(concat('vendor.js'))
|
|
.pipe(gulp.dest('dist/scripts'));
|
|
});
|
|
|
|
gulp.task('styles', ['html'], function() {
|
|
return gulp.src(['src/*.css'])
|
|
.pipe(concat('style.css'))
|
|
.pipe(cleanCSS({
|
|
compatibility: 'ie8'
|
|
}))
|
|
.pipe(license('agpl3', {
|
|
tiny: false,
|
|
project: 'docker-registry-ui',
|
|
year: '2016-2018',
|
|
organization: 'Jones Magloire @Joxit'
|
|
}))
|
|
.pipe(gulp.dest('dist/'));
|
|
});
|
|
|
|
gulp.task('fonts', function() {
|
|
return gulp.src('src/fonts/*')
|
|
.pipe(filter('**/*.{otf,eot,svg,ttf,woff,woff2}'))
|
|
.pipe(gulp.dest('dist/fonts'));
|
|
});
|
|
|
|
gulp.task('sources', ['docker-registry-ui', 'vendor', 'docker-registry-ui-static', 'styles'], function() {
|
|
gulp.start();
|
|
});
|
|
|
|
gulp.task('build', ['clean'], function() {
|
|
gulp.start(['sources', 'fonts']);
|
|
}); |