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'],
|
|
|
|
docs: [docsDir + '/build/docs/**/*'],
|
2017-07-09 17:21:09 +00:00
|
|
|
docstxt: ['docs/**/*.txt'],
|
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: [
|
|
|
|
'**/*.{jpg,jpeg,png,svg,ico}',
|
|
|
|
'!node_modules/**/*.{jpg,jpeg,png,svg,ico}',
|
2017-06-20 14:19:03 +00:00
|
|
|
'!presentations/**/*.{jpg,jpeg,png,svg,ico}',
|
2017-05-30 13:47:46 +00:00
|
|
|
'!public/**/*.{jpg,jpeg,png,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 () {
|
2017-06-07 17:39:08 +00:00
|
|
|
run('cd ' + docsDir + '; make');
|
|
|
|
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
|
|
|
});
|
|
|
|
|
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-07-09 17:21:09 +00:00
|
|
|
gulp.task('htmls', ['docs', 'docstxt'], 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-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-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']);
|