2016-05-13 18:09:12 +02:00
|
|
|
var gulp = require('gulp');
|
|
|
|
var gulpLoadPlugins = require('gulp-load-plugins');
|
|
|
|
var browserSync = require('browser-sync');
|
|
|
|
var del = require('del');
|
|
|
|
|
|
|
|
var $ = gulpLoadPlugins();
|
|
|
|
var reload = browserSync.reload;
|
|
|
|
|
|
|
|
gulp.task('styles', function () {
|
|
|
|
return gulp.src([
|
2016-06-23 16:27:13 +02:00
|
|
|
'src/styles/**/*.css'
|
2016-05-13 18:09:12 +02:00
|
|
|
]).pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
|
|
|
|
.pipe(gulp.dest('.tmp/styles'))
|
|
|
|
.pipe(reload({stream: true}));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('scripts', function () {
|
|
|
|
return gulp.src([
|
2016-06-23 16:27:13 +02:00
|
|
|
'src/scripts/**/*.js'
|
2016-05-13 18:09:12 +02:00
|
|
|
]).pipe($.plumber())
|
|
|
|
.pipe(gulp.dest('.tmp/scripts'))
|
|
|
|
.pipe(reload({stream: true}));
|
|
|
|
});
|
|
|
|
|
2016-08-01 16:15:08 +02:00
|
|
|
gulp.task('views', function () {
|
|
|
|
return gulp.src([
|
|
|
|
'src/views/**/*.html'
|
|
|
|
]).pipe($.htmlmin({collapseWhitespace: true}))
|
|
|
|
.pipe($.angularTemplatecache({module: 'ariaNg', filename: 'views/templates.js', root: 'views/'}))
|
|
|
|
.pipe(gulp.dest('.tmp/scripts'));
|
|
|
|
});
|
|
|
|
|
2016-05-13 18:09:12 +02:00
|
|
|
gulp.task('lint', function () {
|
|
|
|
return gulp.src([
|
2016-06-23 16:27:13 +02:00
|
|
|
'src/scripts/**/*.js'
|
2016-05-13 18:09:12 +02:00
|
|
|
]).pipe(reload({stream: true, once: true}))
|
|
|
|
.pipe($.eslint({fix: true}))
|
|
|
|
.pipe($.eslint.format())
|
|
|
|
.pipe($.if(!browserSync.active, $.eslint.failAfterError()))
|
2016-06-23 16:27:13 +02:00
|
|
|
.pipe(gulp.dest('src/scripts'));
|
2016-05-13 18:09:12 +02:00
|
|
|
});
|
|
|
|
|
2016-08-01 16:15:08 +02:00
|
|
|
gulp.task('html', ['styles', 'scripts', 'views'], function () {
|
2016-06-23 16:27:13 +02:00
|
|
|
return gulp.src('src/*.html')
|
|
|
|
.pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
|
2016-05-13 18:09:12 +02:00
|
|
|
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
|
|
|
|
.pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, '')))
|
|
|
|
.pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'})))
|
|
|
|
.pipe($.if(['css/plugins.min.css', 'css/aria-ng.min.css'], $.cssnano({safe: true, autoprefixer: false})))
|
|
|
|
.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))
|
|
|
|
.pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
2016-05-26 17:52:34 +02:00
|
|
|
gulp.task('langs', function () {
|
2016-06-23 16:27:13 +02:00
|
|
|
return gulp.src('src/langs/**/*')
|
2016-07-16 18:51:23 +02:00
|
|
|
.pipe($.jsonminify())
|
2016-05-26 17:52:34 +02:00
|
|
|
.pipe(gulp.dest('dist/langs'));
|
|
|
|
});
|
|
|
|
|
2016-05-13 18:09:12 +02:00
|
|
|
gulp.task('images', function () {
|
2016-06-23 16:27:13 +02:00
|
|
|
return gulp.src('src/imgs/**/*')
|
2016-05-13 18:09:12 +02:00
|
|
|
.pipe(gulp.dest('dist/imgs'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('fonts', function () {
|
|
|
|
return gulp.src([
|
|
|
|
'bower_components/bootstrap/fonts/**/*',
|
|
|
|
'bower_components/font-awesome/fonts/**/*'
|
|
|
|
]).pipe(gulp.dest('.tmp/fonts'))
|
|
|
|
.pipe(gulp.dest('dist/fonts'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('extras', function () {
|
|
|
|
return gulp.src([
|
2016-06-23 16:27:13 +02:00
|
|
|
'src/*.*',
|
|
|
|
'!src/*.html'
|
2016-05-13 18:09:12 +02:00
|
|
|
], {
|
|
|
|
dot: true
|
|
|
|
}).pipe(gulp.dest('dist'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
|
|
|
|
|
|
|
|
gulp.task('serve', ['styles', 'scripts', 'fonts'], function () {
|
|
|
|
browserSync({
|
|
|
|
notify: false,
|
|
|
|
port: 9000,
|
|
|
|
server: {
|
2016-06-23 16:27:13 +02:00
|
|
|
baseDir: ['.tmp', 'src'],
|
2016-05-13 18:09:12 +02:00
|
|
|
routes: {
|
|
|
|
'/bower_components': 'bower_components'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.watch([
|
2016-06-23 16:27:13 +02:00
|
|
|
'src/*.html',
|
|
|
|
'src/langs/*.json',
|
|
|
|
'src/views/*.html',
|
|
|
|
'src/imgs/**/*',
|
2016-05-13 18:09:12 +02:00
|
|
|
'.tmp/fonts/**/*'
|
|
|
|
]).on('change', reload);
|
|
|
|
|
2016-06-23 16:27:13 +02:00
|
|
|
gulp.watch('src/styles/**/*.css', ['styles']);
|
|
|
|
gulp.watch('src/scripts/**/*.js', ['scripts']);
|
|
|
|
gulp.watch('src/fonts/**/*', ['fonts']);
|
2016-05-13 18:09:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('serve:dist', function () {
|
|
|
|
browserSync({
|
|
|
|
notify: false,
|
|
|
|
port: 9000,
|
|
|
|
server: {
|
|
|
|
baseDir: ['dist']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-08-01 16:15:08 +02:00
|
|
|
gulp.task('build', ['lint', 'html', 'langs', 'images', 'fonts', 'extras'], function () {
|
2016-05-13 18:09:12 +02:00
|
|
|
return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('default', ['clean'], function () {
|
|
|
|
gulp.start('build');
|
|
|
|
});
|