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-05-30 13:47:46 +00:00
|
|
|
var docsDir = '../doc/reference';
|
2017-04-10 14:24:53 +00:00
|
|
|
|
|
|
|
var paths = {
|
2017-05-30 13:47:46 +00:00
|
|
|
htmls: [
|
|
|
|
'**/*.html',
|
2017-06-16 14:38:22 +00:00
|
|
|
'!deprecated/reference_ru.html',
|
|
|
|
'!deprecated/reference_en.html',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!node_modules/**/*.html',
|
|
|
|
'!public/**/*.html'],
|
2017-06-16 14:38:22 +00:00
|
|
|
reference: ['deprecated/reference_ru.html', 'deprecated/reference_en.html'],
|
2017-05-30 13:47:46 +00:00
|
|
|
docs: ['../doc/reference/build/docs/**/*'],
|
|
|
|
scripts: [
|
|
|
|
'**/*.js',
|
|
|
|
'!gulpfile.js',
|
|
|
|
'!node_modules/**/*.js',
|
|
|
|
'!public/**/*.js'],
|
|
|
|
styles: [
|
|
|
|
'**/*.css',
|
|
|
|
'!node_modules/**/*.css',
|
|
|
|
'!public/**/*.css'],
|
|
|
|
images: [
|
|
|
|
'**/*.{jpg,jpeg,png,svg,ico}',
|
|
|
|
'!node_modules/**/*.{jpg,jpeg,png,svg,ico}',
|
|
|
|
'!public/**/*.{jpg,jpeg,png,svg,ico}'],
|
2017-04-10 14:24:53 +00:00
|
|
|
robotstxt: ['robots.txt'],
|
2017-06-19 11:38:54 +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-16 14:38:22 +00:00
|
|
|
.pipe(gulp.dest(outputDir + '/deprecated'))
|
2017-04-10 14:24:53 +00:00
|
|
|
});
|
|
|
|
|
2017-06-01 18:30:42 +00:00
|
|
|
gulp.task('docstxt', [], function () {
|
|
|
|
run('cd ' + docsDir + '; make');
|
2017-06-02 20:00:21 +00:00
|
|
|
return gulp.src(paths.docs)
|
|
|
|
.pipe(gulp.dest(outputDir + '/../docs'))
|
2017-06-01 18:30:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('docs', ['docstxt'], function () {
|
2017-05-30 13:47:46 +00:00
|
|
|
run('cd ' + docsDir + '; make');
|
2017-05-16 16:00:24 +00:00
|
|
|
return gulp.src(paths.docs)
|
2017-05-30 13:47:46 +00:00
|
|
|
.pipe(gulp.dest(outputDir + '/../docs'))
|
2017-05-16 16:00:24 +00:00
|
|
|
});
|
|
|
|
|
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))
|
|
|
|
});
|
|
|
|
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.task('htmls', ['docs'], 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-05-30 13:47:46 +00:00
|
|
|
gulp.task('scripts', ['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-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-05-30 13:47:46 +00:00
|
|
|
.pipe(cleanCss({inline: ['none']}))
|
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-05-30 13:47:46 +00:00
|
|
|
gulp.task('build', ['htmls', 'robotstxt', 'reference', 'presentations', 'scripts', 'styles', 'images']);
|
2017-04-10 14:24:53 +00:00
|
|
|
|
2017-05-30 13:47:46 +00:00
|
|
|
gulp.task('default', ['build', 'connect']);
|