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'),
|
2020-06-03 23:02:39 +02:00
|
|
|
mustache = require('gulp-mustache'),
|
2015-08-29 15:24:20 +02:00
|
|
|
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
|
|
|
// JS task
|
|
|
|
gulp.task('js', function() {
|
|
|
|
return gulp.src([
|
2020-06-03 23:02:39 +02:00
|
|
|
'node_modules/jquery/dist/jquery.js',
|
|
|
|
'node_modules/handlebars/dist/handlebars.js',
|
|
|
|
'node_modules/handlebars-intl/dist/handlebars-intl-with-locales.js',
|
|
|
|
'node_modules/sammy/lib/sammy.js',
|
|
|
|
'node_modules/sammy/lib/plugins/sammy.handlebars.js',
|
|
|
|
'node_modules/sammy/lib/plugins/sammy.json.js',
|
|
|
|
'node_modules/sammy/lib/plugins/sammy.storage.js',
|
|
|
|
'node_modules/bootstrap/dist/js/bootstrap.js',
|
|
|
|
'node_modules/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() {
|
2020-06-04 00:08:58 +02:00
|
|
|
return gulp.src('js/**/*.js')
|
2015-08-29 15:24:20 +02:00
|
|
|
.pipe(jshint())
|
2020-06-04 00:31:41 +02:00
|
|
|
.pipe(jshint.reporter('default'))
|
|
|
|
.pipe(jshint.reporter('fail'))
|
2015-08-29 15:24:20 +02:00
|
|
|
});
|
|
|
|
|
2016-03-05 11:23:13 +01:00
|
|
|
// Fonts
|
|
|
|
gulp.task('fonts', function() {
|
|
|
|
return gulp.src([
|
2020-06-03 23:02:39 +02:00
|
|
|
'node_modules/fork-awesome/fonts/*',
|
|
|
|
'node_modules/source-code-pro/EOT/*.eot',
|
|
|
|
'node_modules/source-code-pro/OTF/*.otf',
|
|
|
|
'node_modules/source-code-pro/TTF/*.ttf',
|
|
|
|
'node_modules/source-code-pro/WOFF/OTF/*.woff',
|
|
|
|
'node_modules/source-code-pro/WOFF2/TTF/*.woff2',
|
|
|
|
'node_modules/source-sans-pro/EOT/*.eot',
|
|
|
|
'node_modules/source-sans-pro/OTF/*.otf',
|
|
|
|
'node_modules/source-sans-pro/TTF/*.ttf',
|
|
|
|
'node_modules/source-sans-pro/WOFF/OTF/*.woff',
|
|
|
|
'node_modules/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())
|
2020-06-04 00:08:58 +02:00
|
|
|
.pipe(csslint.formatter())
|
2015-09-03 09:31:04 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
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'))
|
|
|
|
});
|
2020-06-03 23:02:39 +02:00
|
|
|
|
|
|
|
// Views task
|
|
|
|
gulp.task('views', function () {
|
|
|
|
return gulp.src('views/**/*.ms')
|
|
|
|
.pipe(gulp.dest("./dist/views"));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Global build task
|
|
|
|
gulp.task('build', gulp.series('css', 'fonts', 'js', 'img', 'views'));
|
|
|
|
|
|
|
|
// Watch task
|
|
|
|
gulp.task('watch', function() {
|
|
|
|
gulp.watch('js/**/*.js', gulp.series('js'));
|
|
|
|
gulp.watch('css/*.less', gulp.series('css'));
|
|
|
|
gulp.watch('views/**/*.ms', gulp.series('views'));
|
2020-06-04 00:08:42 +02:00
|
|
|
});
|
|
|
|
|
2020-06-04 00:08:58 +02:00
|
|
|
gulp.task('lint', gulp.series('css-lint', 'js-lint'));
|
|
|
|
|
2020-06-04 00:08:42 +02:00
|
|
|
gulp.task('default', gulp.series('build', 'watch'));
|