2017-04-10 14:24:53 +00:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var concat = require('gulp-concat');
|
|
|
|
var uglify = require('gulp-uglify');
|
|
|
|
var cleanCss = require('gulp-clean-css');
|
|
|
|
var imagemin = require('gulp-imagemin');
|
|
|
|
var sourcemaps = require('gulp-sourcemaps');
|
|
|
|
var htmlmin = require('gulp-htmlmin');
|
|
|
|
var minifyInline = require('gulp-minify-inline');
|
|
|
|
var del = require('del');
|
|
|
|
var connect = require('gulp-connect');
|
2017-05-16 16:00:24 +00:00
|
|
|
var run = require('gulp-run');
|
2017-04-10 14:24:53 +00:00
|
|
|
|
|
|
|
var outputDir = 'public';
|
2017-06-20 14:19:03 +00:00
|
|
|
var docsDir = '../docs';
|
2017-04-10 14:24:53 +00:00
|
|
|
|
|
|
|
var paths = {
|
2017-05-30 13:47:46 +00:00
|
|
|
htmls: [
|
|
|
|
'**/*.html',
|
2017-06-20 14:19:03 +00:00
|
|
|
'!deprecated/reference_ru.html',
|
|
|
|
'!deprecated/reference_en.html',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!node_modules/**/*.html',
|
2017-06-20 14:19:03 +00:00
|
|
|
'!presentations/**/*.html',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!public/**/*.html'],
|
2017-06-20 14:19:03 +00:00
|
|
|
reference: ['deprecated/reference_ru.html', 'deprecated/reference_en.html'],
|
2018-07-09 19:59:07 +00:00
|
|
|
docs: [docsDir + '/build/**/*'],
|
|
|
|
docstxt: ['docs/**/*.txt', 'docs/redirects.conf'],
|
2018-02-12 22:05:44 +00:00
|
|
|
docsjson: ['docs/**/*.json'],
|
|
|
|
docsxml: ['docs/**/*.xml'],
|
2018-02-13 14:11:45 +00:00
|
|
|
docssitemap: ['sitemap.xml'],
|
2017-05-30 13:47:46 +00:00
|
|
|
scripts: [
|
|
|
|
'**/*.js',
|
|
|
|
'!gulpfile.js',
|
|
|
|
'!node_modules/**/*.js',
|
2017-06-20 14:19:03 +00:00
|
|
|
'!presentations/**/*.js',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!public/**/*.js'],
|
|
|
|
styles: [
|
|
|
|
'**/*.css',
|
|
|
|
'!node_modules/**/*.css',
|
2017-06-20 14:19:03 +00:00
|
|
|
'!presentations/**/*.css',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!public/**/*.css'],
|
|
|
|
images: [
|
2018-07-20 17:35:34 +00:00
|
|
|
'**/*.{jpg,jpeg,png,gif,svg,ico}',
|
|
|
|
'!node_modules/**/*.{jpg,jpeg,png,gif,svg,ico}',
|
|
|
|
'!presentations/**/*.{jpg,jpeg,png,gif,svg,ico}',
|
|
|
|
'!public/**/*.{jpg,jpeg,png,gif,svg,ico}'],
|
2017-04-10 14:24:53 +00:00
|
|
|
robotstxt: ['robots.txt'],
|
2017-06-20 14:19:03 +00:00
|
|
|
presentations: ['presentations/**/*']
|
2017-04-10 14:24:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
gulp.task('clean', function () {
|
2017-05-16 16:00:24 +00:00
|
|
|
return del([outputDir + '/**']);
|
2017-04-10 14:24:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('reference', [], function () {
|
|
|
|
return gulp.src(paths.reference)
|
|
|
|
.pipe(minifyInline())
|
2017-06-20 14:19:03 +00:00
|
|
|
.pipe(gulp.dest(outputDir + '/deprecated'))
|
2017-04-10 14:24:53 +00:00
|
|
|
});
|
|
|
|
|
2017-07-09 17:21:09 +00:00
|
|
|
gulp.task('docs', [], function () {
|
2018-07-09 19:59:07 +00:00
|
|
|
run('cd ' + docsDir + '/tools; ./build.py');
|
2017-06-07 17:39:08 +00:00
|
|
|
return gulp.src(paths.docs)
|
|
|
|
.pipe(gulp.dest(outputDir + '/../docs'))
|
|
|
|
});
|
|
|
|
|
2017-07-09 17:21:09 +00:00
|
|
|
gulp.task('docstxt', ['docs'], function () {
|
|
|
|
return gulp.src(paths.docstxt)
|
|
|
|
.pipe(gulp.dest(outputDir + '/docs'))
|
2017-05-16 16:00:24 +00:00
|
|
|
});
|
|
|
|
|
2018-02-12 22:05:44 +00:00
|
|
|
gulp.task('docsjson', ['docs'], function () {
|
|
|
|
return gulp.src(paths.docsjson)
|
|
|
|
.pipe(gulp.dest(outputDir + '/docs'))
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('docsxml', ['docs'], function () {
|
|
|
|
return gulp.src(paths.docsxml)
|
|
|
|
.pipe(gulp.dest(outputDir + '/docs'))
|
|
|
|
});
|
|
|
|
|
2018-02-13 14:11:45 +00:00
|
|
|
gulp.task('docssitemap', [], function () {
|
|
|
|
return gulp.src(paths.docssitemap)
|
|
|
|
.pipe(gulp.dest(outputDir + '/docs'))
|
|
|
|
});
|
|
|
|
|
2017-04-10 14:24:53 +00:00
|
|
|
gulp.task('presentations', [], function () {
|
|
|
|
return gulp.src(paths.presentations)
|
|
|
|
.pipe(gulp.dest(outputDir + '/presentations'))
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('robotstxt', [], function () {
|
|
|
|
return gulp.src(paths.robotstxt)
|
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
2018-02-13 14:11:45 +00:00
|
|
|
gulp.task('htmls', ['docs', 'docstxt', 'docsjson', 'docsxml', 'docssitemap'], function () {
|
2017-04-10 14:24:53 +00:00
|
|
|
return gulp.src(paths.htmls)
|
|
|
|
.pipe(htmlmin({collapseWhitespace: true}))
|
|
|
|
.pipe(minifyInline())
|
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
2017-08-04 14:52:08 +00:00
|
|
|
gulp.task('sourcemaps', ['docs'], function () {
|
2017-04-10 14:24:53 +00:00
|
|
|
return gulp.src(paths.scripts)
|
|
|
|
.pipe(sourcemaps.init())
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(sourcemaps.write())
|
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
2017-08-04 14:52:08 +00:00
|
|
|
gulp.task('scripts', ['docs'], function () {
|
|
|
|
return gulp.src(paths.scripts)
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.task('styles', ['docs'], function () {
|
2017-04-10 14:24:53 +00:00
|
|
|
return gulp.src(paths.styles)
|
2017-12-29 15:45:21 +00:00
|
|
|
.pipe(cleanCss())
|
2017-04-10 14:24:53 +00:00
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.task('images', ['docs'], function () {
|
2017-04-10 14:24:53 +00:00
|
|
|
return gulp.src(paths.images)
|
|
|
|
.pipe(imagemin({optimizationLevel: 9}))
|
|
|
|
.pipe(gulp.dest(outputDir))
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('watch', function () {
|
|
|
|
gulp.watch(paths.htmls, ['htmls']);
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.watch(paths.docs, ['docs']);
|
2017-05-30 10:45:59 +00:00
|
|
|
gulp.watch(paths.reference, ['reference']);
|
2017-04-10 14:24:53 +00:00
|
|
|
gulp.watch(paths.scripts, ['scripts']);
|
|
|
|
gulp.watch(paths.images, ['images']);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('connect', function() {
|
|
|
|
connect.server({
|
|
|
|
root: outputDir,
|
|
|
|
port: 8080,
|
|
|
|
keepalive: true,
|
|
|
|
livereload: true
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
2017-06-20 14:19:03 +00:00
|
|
|
gulp.task('build', ['htmls', 'robotstxt', 'reference', 'scripts', 'styles', 'images', 'presentations']);
|
2017-04-10 14:24:53 +00:00
|
|
|
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.task('default', ['build', 'connect']);
|