Aggiornamento a Gulp4

This commit is contained in:
Thomas Zilio 2020-06-30 13:24:55 +02:00
parent b11558824c
commit 5ab5ac2bf6
3 changed files with 169 additions and 192 deletions

View File

@ -35,22 +35,24 @@ $(document).ready(function () {
};
// Imposta lo standard per la conversione dei numeri
numeral.register('locale', 'current', {
delimiters: {
thousands: globals.thousands,
decimal: globals.decimals,
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
currency: {
symbol: '€'
}
});
numeral.locale('current');
if (numeral.locales['current_locale'] === undefined) {
numeral.register('locale', 'current_locale', {
delimiters: {
thousands: globals.thousands,
decimal: globals.decimals,
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
currency: {
symbol: '€'
}
});
}
numeral.locale('current_locale');
numeral.defaultFormat('0,0.' + ('0').repeat(globals.cifre_decimali));
// Richiamo alla generazione di Datatables

View File

@ -1,8 +1,8 @@
// Librerie NPM richieste per l'esecuzione
var gulp = require('gulp');
var merge = require('merge-stream');
var del = require('del');
var debug = require('gulp-debug');
var util = require('gulp-util');
var shell = require('shelljs');
var mainBowerFiles = require('main-bower-files');
@ -45,65 +45,59 @@ var config = {
};
// Elaborazione e minificazione di JS
gulp.task('JS', function () {
gulp.src(mainBowerFiles('**/*.js', {
paths: config.main,
debugging: config.debug,
}))
const JS = gulp.parallel(() => {
return gulp.src(mainBowerFiles('**/*.js', {
paths: config.main,
debugging: config.debug,
}))
.pipe(concat('app.min.js'))
.pipe(minifyJS()) // Commentare per togliere la minificazione
//.pipe(minifyJS())
.pipe(gulp.dest(config.production + '/' + config.paths.js));
gulp.start('srcJS');
});
}, srcJS);
// Elaborazione e minificazione di JS personalizzati
gulp.task('srcJS', function () {
gulp.src([
config.development + '/' + config.paths.js + '/*.js',
])
function srcJS() {
var js = gulp.src([
config.development + '/' + config.paths.js + '/*.js',
])
.pipe(concat('custom.min.js'))
.pipe(minifyJS()) // Commentare per togliere la minificazione
.pipe(minifyJS())
.pipe(gulp.dest(config.production + '/' + config.paths.js));
gulp.src([
var indip = gulp.src([
config.development + '/' + config.paths.js + '/functions/*.js',
])
.pipe(concat('functions.min.js'))
.pipe(minifyJS()) // Commentare per togliere la minificazione
.pipe(minifyJS())
.pipe(gulp.dest(config.production + '/' + config.paths.js));
});
return merge(js, indip);
}
// Elaborazione e minificazione di CSS
gulp.task('CSS', function () {
gulp.src(mainBowerFiles('**/*.{css,scss,less,styl}', {
paths: config.main,
debugging: config.debug,
}))
const CSS = gulp.parallel(() => {
return gulp.src(mainBowerFiles('**/*.{css,scss,less,styl}', {
paths: config.main,
debugging: config.debug,
}))
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
.pipe(autoprefixer({
browsers: 'last 2 version',
}))
.pipe(autoprefixer())
.pipe(minifyCSS({
rebase: false,
}))
.pipe(concat('app.min.css'))
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.css));
gulp.start('srcCSS');
});
}, srcCSS);
// Elaborazione e minificazione di CSS personalizzati
gulp.task('srcCSS', function () {
gulp.src([
config.development + '/' + config.paths.css + '/*.{css,scss,less,styl}',
])
function srcCSS() {
var css = gulp.src([
config.development + '/' + config.paths.css + '/*.{css,scss,less,styl}',
])
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
.pipe(autoprefixer({
browsers: 'last 2 version',
}))
.pipe(autoprefixer())
.pipe(minifyCSS({
rebase: false,
}))
@ -111,14 +105,14 @@ gulp.task('srcCSS', function () {
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.css));
gulp.src([
config.development + '/' + config.paths.css + '/print/*.{css,scss,less,styl}',
config.bowerDirectory + '/fullcalendar/fullcalendar.print.css',
])
var print = gulp.src([
config.development + '/' + config.paths.css + '/print/*.{css,scss,less,styl}',
config.bowerDirectory + '/fullcalendar/fullcalendar.print.css',
], {
allowEmpty: true
})
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
.pipe(autoprefixer({
browsers: 'last 2 version',
}))
.pipe(autoprefixer())
.pipe(minifyCSS({
rebase: false,
}))
@ -126,144 +120,145 @@ gulp.task('srcCSS', function () {
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.css));
gulp.src([
config.development + '/' + config.paths.css + '/themes/*.{css,scss,less,styl}',
config.main.bowerDirectory + '/admin-lte/dist/css/skins/_all-skins.css',
])
var themes = gulp.src([
config.development + '/' + config.paths.css + '/themes/*.{css,scss,less,styl}',
])
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
.pipe(autoprefixer({
browsers: 'last 2 version',
}))
.pipe(autoprefixer())
.pipe(minifyCSS({
rebase: false,
}))
.pipe(concat('themes.min.css'))
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.css));
});
return merge(css, print, themes);
}
// Elaborazione delle immagini
gulp.task('images', function () {
gulp.src(mainBowerFiles('**/*.{jpg,png,jpeg,gif}', {
paths: config.main,
debugging: config.debug,
}))
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.images));
gulp.start('srcImages');
const images = srcImages;
/*
gulp.parallel(() => {*/
//var src = mainBowerFiles('**/*.{jpg,png,jpeg,gif}', {
/*
paths: config.main,
debugging: config.debug,
});
return gulp.src(src, {
allowEmpty: true
})
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.images));
}, srcImages);
*/
// Elaborazione delle immagini personalizzate
gulp.task('srcImages', function () {
gulp.src([
config.development + '/' + config.paths.images + '/**/*.{jpg,png,jpeg,gif}',
])
function srcImages() {
return gulp.src([
config.development + '/' + config.paths.images + '/**/*.{jpg,png,jpeg,gif}',
])
.pipe(gulp.dest(config.production + '/' + config.paths.images));
});
}
// Elaborazione dei fonts
gulp.task('fonts', function () {
gulp.src(mainBowerFiles('**/*.{otf,eot,svg,ttf,woff,woff2}', {
paths: config.main,
debugging: config.debug,
}))
const fonts = gulp.parallel(() => {
return gulp.src(mainBowerFiles('**/*.{otf,eot,svg,ttf,woff,woff2}', {
paths: config.main,
debugging: config.debug,
}))
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
gulp.start('srcFonts');
});
}, srcFonts);
// Elaborazione dei fonts personalizzati
gulp.task('srcFonts', function () {
gulp.src([
config.development + '/' + config.paths.fonts + '/**/*.{otf,eot,svg,ttf,woff,woff2}',
])
function srcFonts() {
return gulp.src([
config.development + '/' + config.paths.fonts + '/**/*.{otf,eot,svg,ttf,woff,woff2}',
])
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
});
}
gulp.task('ckeditor', function () {
gulp.src([
config.main.bowerDirectory + '/ckeditor/{adapters,lang,skins,plugins}/**/*.{js,json,css,png}',
])
function ckeditor() {
return gulp.src([
config.main.bowerDirectory + '/@ckeditor/ckeditor5-build-classic/build/**/*.{js,json,css,png}',
])
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor'));
}
gulp.src([
config.main.bowerDirectory + '/ckeditor/*.{js,css}',
])
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor'));
});
gulp.task('colorpicker', function () {
gulp.src([
config.main.bowerDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}',
])
function colorpicker() {
return gulp.src([
config.main.bowerDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}',
])
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/bootstrap-colorpicker'));
});
}
gulp.task('password-strength', function () {
gulp.src([
function password_strength(){
return gulp.src([
config.main.bowerDirectory + '/pwstrength-bootstrap/dist/*.js',
])
.pipe(concat('password.min.js'))
.pipe(minifyJS())
.pipe(gulp.dest(config.production + '/password-strength'));
});
}
gulp.task('hotkeys-js', function () {
gulp.src([
function hotkeys() {
return gulp.src([
config.main.bowerDirectory + '/hotkeys-js/dist/hotkeys.min.js',
])
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/hotkeys-js'));
});
}
gulp.task('chartjs', function () {
gulp.src([
config.main.bowerDirectory + '/chart.js/dist/Chart.min.js',
])
function chartjs() {
return gulp.src([
config.main.bowerDirectory + '/chart.js/dist/Chart.min.js',
])
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/chartjs'));
});
}
gulp.task('csrf', function () {
gulp.src([
'./vendor/owasp/csrf-protector-php/js/csrfprotector.js',
])
function csrf() {
return gulp.src([
'./vendor/owasp/csrf-protector-php/js/csrfprotector.js',
])
.pipe(flatten())
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/csrf'));
});
}
gulp.task('pdfjs', function () {
gulp.src([
config.main.bowerDirectory + '/pdf/web/**/*',
'!' + config.main.bowerDirectory + '/pdf/web/cmaps/*',
'!' + config.main.bowerDirectory + '/pdf/web/*.map',
'!' + config.main.bowerDirectory + '/pdf/web/*.pdf',
])
function pdfjs() {
var web = gulp.src([
config.main.bowerDirectory + '/pdf/web/**/*',
'!' + config.main.bowerDirectory + '/pdf/web/cmaps/*',
'!' + config.main.bowerDirectory + '/pdf/web/*.map',
'!' + config.main.bowerDirectory + '/pdf/web/*.pdf',
])
.pipe(gulp.dest(config.production + '/pdfjs/web'));
gulp.src([
config.main.bowerDirectory + '/pdf/build/*',
'!' + config.main.bowerDirectory + '/pdf/build/*.map',
])
var build = gulp.src([
config.main.bowerDirectory + '/pdf/build/*',
'!' + config.main.bowerDirectory + '/pdf/build/*.map',
])
.pipe(gulp.dest(config.production + '/pdfjs/build'));
});
return merge(web, build);
}
// Elaborazione e minificazione delle informazioni sull'internazionalizzazione
gulp.task('i18n', function () {
gulp.src([
config.main.bowerDirectory + '/**/{i18n,lang,locale,locales}/*.{js,json}',
config.development + '/' + config.paths.js + '/i18n/**/*.{js,json}',
'!' + config.main.bowerDirectory + '/**/{src,plugins}/**',
'!' + config.main.bowerDirectory + '/ckeditor/**',
'!' + config.main.bowerDirectory + '/jquery-ui/**',
])
.pipe(gulpIf('*.js', minifyJS(), gulpIf('*.json', minifyJSON())))
function i18n() {
return gulp.src([
config.main.bowerDirectory + '/**/{i18n,lang,locale,locales}/*.{js,json}',
config.development + '/' + config.paths.js + '/i18n/**/*.{js,json}',
'!' + config.main.bowerDirectory + '/**/{src,plugins}/**',
'!' + config.main.bowerDirectory + '/ckeditor/**',
'!' + config.main.bowerDirectory + '/summernote/**',
'!' + config.main.bowerDirectory + '/jquery-ui/**',
])
//.pipe(gulpIf('*.js', minifyJS(), gulpIf('*.json', minifyJSON())))
.pipe(gulpIf('!*.min.*', rename({
suffix: '.min'
})))
@ -271,20 +266,20 @@ gulp.task('i18n', function () {
includeParents: 1
}))
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/i18n'));
});
}
// PHP DebugBar assets
gulp.task('php-debugbar', function () {
gulp.src([
'./vendor/maximebf/debugbar/src/DebugBar/Resources/**/*',
'!./vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/**/*',
])
function phpDebugBar() {
return gulp.src([
'./vendor/maximebf/debugbar/src/DebugBar/Resources/**/*',
'!./vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/**/*',
])
.pipe(gulpIf('*.css', minifyCSS(), gulpIf('*.js', minifyJS())))
.pipe(gulp.dest(config.production + '/php-debugbar'));
});
}
// Operazioni per la release
gulp.task('release', function () {
function release() {
var archiver = require('archiver');
var fs = require('fs');
@ -372,35 +367,16 @@ gulp.task('release', function () {
// Completamento dello zip
archive.finalize();
});
});
}
// Pulizia
gulp.task('clean', function () {
function clean() {
return del([config.production]);
});
}
// Operazioni di default per la generazione degli assets
gulp.task('bower', ['clean'], function () {
gulp.start('JS');
gulp.start('CSS');
gulp.start('images');
gulp.start('fonts');
gulp.start('other');
});
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, phpDebugBar, ckeditor, colorpicker, i18n, pdfjs, hotkeys, chartjs, password_strength, csrf));
// Operazioni particolari per la generazione degli assets
gulp.task('other', ['clean'], function () {
gulp.start('ckeditor');
gulp.start('colorpicker');
gulp.start('password-strength');
gulp.start('hotkeys-js');
gulp.start('i18n');
gulp.start('pdfjs');
gulp.start('chartjs');
gulp.start('php-debugbar');
gulp.start('csrf');
});
gulp.task('default', ['clean', 'bower']);
exports.bower = bower;
exports.release = release;
exports.default = bower;

View File

@ -40,23 +40,22 @@
"tooltipster": "^4.2.5"
},
"devDependencies": {
"archiver": "^2.0.0",
"concurrently": "^3.6.1",
"archiver": "^3.0.0",
"cwd": "^0.10.0",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.1",
"gulp-clean-css": "^2.3.2",
"del": "^4.0.0",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^7.0.0",
"gulp-clean-css": "^4.0.0",
"gulp-concat": "^2.6.0",
"gulp-debug": "^3.1.0",
"gulp-flatten": "^0.2.0",
"gulp-debug": "^4.0.0",
"gulp-flatten": "^0.4.0",
"gulp-if": "^2.0.2",
"gulp-json-minify": "^1.0.5",
"gulp-less": "^3.3.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^3.1.0",
"gulp-less": "^4.0.1",
"gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2",
"gulp-stylus": "^2.6.0",
"gulp-uglify": "^2.0.0",
"gulp-uglify": "^3.0.2",
"gulp-util": "^3.0.8",
"inquirer": "^4.0.1",
"main-bower-files": "^2.13.1",