2015-08-29 15:24:20 +02:00
|
|
|
// Include Gulp
|
|
|
|
var gulp = require('gulp');
|
|
|
|
|
|
|
|
// Include required Gulp packages
|
|
|
|
var concat = require('gulp-concat'),
|
|
|
|
uglify = require('gulp-uglify'),
|
2015-09-03 09:31:04 +02:00
|
|
|
csslint = require('gulp-csslint'),
|
2015-08-29 15:24:20 +02:00
|
|
|
jshint = require('gulp-jshint'),
|
|
|
|
less = require('gulp-less'),
|
|
|
|
autoprefixer = require('gulp-autoprefixer'),
|
|
|
|
cssmin = require('gulp-cssmin'),
|
|
|
|
imagemin = require('gulp-imagemin'),
|
|
|
|
rename = require('gulp-rename')
|
2016-04-28 16:18:07 +02:00
|
|
|
util = require('gulp-util')
|
|
|
|
gulpif = require('gulp-if')
|
2015-08-29 15:24:20 +02:00
|
|
|
;
|
|
|
|
|
2016-04-28 16:18:07 +02:00
|
|
|
// Environment variables
|
|
|
|
isDev = (util.env.dev) ? true : false;
|
|
|
|
isProduction = !isDev;
|
|
|
|
|
2015-08-29 15:24:20 +02:00
|
|
|
// Global build task
|
|
|
|
gulp.task('build', [
|
|
|
|
'css',
|
2016-03-05 11:23:13 +01:00
|
|
|
'fonts',
|
2015-08-29 15:24:20 +02:00
|
|
|
'js',
|
|
|
|
'img',
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
2015-08-31 11:01:17 +02:00
|
|
|
// Watch task
|
|
|
|
gulp.task('watch', function(){
|
2016-03-15 21:33:35 +01:00
|
|
|
gulp.watch('js/**/*.js', ['js']);
|
2015-08-31 11:01:17 +02:00
|
|
|
gulp.watch('css/*.less', ['css']);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-08-29 15:24:20 +02:00
|
|
|
// JS task
|
|
|
|
gulp.task('js', function() {
|
|
|
|
return gulp.src([
|
2016-03-04 14:40:05 +01:00
|
|
|
'bower_components/jquery/dist/jquery.js',
|
2016-03-05 11:51:52 +01:00
|
|
|
'bower_components/js-cookie/src/js.cookie.js',
|
2016-03-04 14:40:05 +01:00
|
|
|
'bower_components/handlebars/handlebars.js',
|
2018-05-26 03:18:32 +02:00
|
|
|
'bower_components/handlebars-helper-intl/dist/handlebars-intl-with-locales.js',
|
2016-03-04 14:40:05 +01:00
|
|
|
'bower_components/sammy/lib/sammy.js',
|
|
|
|
'bower_components/sammy/lib/plugins/sammy.handlebars.js',
|
|
|
|
'bower_components/sammy/lib/plugins/sammy.json.js',
|
|
|
|
'bower_components/sammy/lib/plugins/sammy.storage.js',
|
|
|
|
'bower_components/bootstrap/dist/js/bootstrap.js',
|
2018-08-30 23:56:46 +02:00
|
|
|
'bower_components/isotope-layout/dist/isotope.pkgd.js',
|
2015-11-24 08:36:36 +01:00
|
|
|
'js/yunohost/y18n.js',
|
2016-02-04 12:14:37 +01:00
|
|
|
'js/yunohost/main.js',
|
2015-11-24 08:36:36 +01:00
|
|
|
'js/yunohost/helpers.js',
|
|
|
|
'js/yunohost/filters.js',
|
2017-02-25 04:30:20 +01:00
|
|
|
'js/yunohost/events.js',
|
2015-11-24 08:36:36 +01:00
|
|
|
'js/yunohost/controllers/*.js',
|
2015-08-29 15:24:20 +02:00
|
|
|
])
|
2016-04-28 16:18:07 +02:00
|
|
|
.pipe(gulpif(isProduction, uglify()))
|
2015-08-29 15:24:20 +02:00
|
|
|
.pipe(concat('script.min.js'))
|
|
|
|
.pipe(gulp.dest('./dist/js'))
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// JS Lint task
|
|
|
|
gulp.task('js-lint', function() {
|
|
|
|
return gulp.src('js/*.js')
|
|
|
|
.pipe(jshint())
|
|
|
|
.pipe(jshint.reporter('default'));
|
|
|
|
});
|
|
|
|
|
2016-03-05 11:23:13 +01:00
|
|
|
// Fonts
|
|
|
|
gulp.task('fonts', function() {
|
|
|
|
return gulp.src([
|
2019-10-15 19:53:35 +02:00
|
|
|
'bower_components/fork-awesome/fonts/*',
|
2016-03-05 15:10:39 +01:00
|
|
|
'bower_components/source-code-pro/EOT/*.eot',
|
|
|
|
'bower_components/source-code-pro/OTF/*.otf',
|
|
|
|
'bower_components/source-code-pro/TTF/*.ttf',
|
|
|
|
'bower_components/source-code-pro/WOFF/OTF/*.woff',
|
|
|
|
'bower_components/source-code-pro/WOFF2/TTF/*.woff2',
|
|
|
|
'bower_components/source-sans-pro/EOT/*.eot',
|
|
|
|
'bower_components/source-sans-pro/OTF/*.otf',
|
|
|
|
'bower_components/source-sans-pro/TTF/*.ttf',
|
|
|
|
'bower_components/source-sans-pro/WOFF/OTF/*.woff',
|
|
|
|
'bower_components/source-sans-pro/WOFF2/TTF/*.woff2',
|
2016-03-05 11:23:13 +01:00
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./dist/fonts'))
|
|
|
|
});
|
2015-08-29 15:24:20 +02:00
|
|
|
|
|
|
|
// CSS task
|
|
|
|
gulp.task('css', function () {
|
|
|
|
return gulp.src('css/style.less')
|
|
|
|
.pipe(less())
|
|
|
|
.pipe(autoprefixer())
|
|
|
|
.pipe(rename({
|
|
|
|
suffix: '.min'
|
|
|
|
}))
|
2016-04-28 16:18:07 +02:00
|
|
|
.pipe(gulpif(isProduction, cssmin()))
|
2015-08-29 15:24:20 +02:00
|
|
|
.pipe(gulp.dest('./dist/css'))
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-09-03 09:31:04 +02:00
|
|
|
// CSS/Less lint task
|
|
|
|
gulp.task('css-lint', function() {
|
|
|
|
return gulp.src('css/style.less')
|
|
|
|
.pipe(less())
|
|
|
|
.pipe(autoprefixer())
|
|
|
|
.pipe(csslint())
|
|
|
|
.pipe(csslint.reporter('compact'))
|
|
|
|
.pipe(gulp.dest('./css/'))
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-08-29 15:24:20 +02:00
|
|
|
// Images task
|
|
|
|
gulp.task('img', function () {
|
|
|
|
return gulp.src('img/*')
|
2016-04-28 16:18:07 +02:00
|
|
|
.pipe(gulpif(isProduction, imagemin()))
|
2015-08-29 15:24:20 +02:00
|
|
|
.pipe(gulp.dest('./dist/img'))
|
|
|
|
});
|