forked from CatoTH/antragsgruen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
121 lines (108 loc) · 4.86 KB
/
Copy pathgulpfile.js
File metadata and controls
121 lines (108 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
'use strict';
import autoprefixer from 'autoprefixer';
import gulp from 'gulp';
import concat from 'gulp-concat';
import postcss from 'gulp-postcss';
import sourcemaps from 'gulp-sourcemaps';
import terser from 'gulp-terser';
import { createVueTransform } from "./assets/gulpfile.vue.js";
// SASS
import * as dartSass from 'sass';
import gulpSass from 'gulp-sass';
const sass = gulpSass(dartSass);
const main_js_files = [
"node_modules/entreprise7pro-bootstrap/js/tooltip.js",
"node_modules/entreprise7pro-bootstrap/js/dropdown.js",
"node_modules/entreprise7pro-bootstrap/js/modal.js",
"node_modules/entreprise7pro-bootstrap/js/popover.js",
"node_modules/bootbox/dist/bootbox.all.js",
"web_src/js/jquery.isonscreen.js",
"web_src/js/antragsgruen.js",
];
async function taskCopyFiles() {
await gulp.src("node_modules/@selectize/selectize/dist/js/selectize.min.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/bootstrap-toggle/js/bootstrap-toggle.min.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/clipboard/dist/clipboard.min.js").pipe(terser()).pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/isotope-layout/dist/isotope.pkgd.min.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/moment/min/moment-with-locales.min.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/sortablejs/Sortable.min.js").pipe(gulp.dest('./web/npm/'));
//await gulp.src("node_modules/vue-draggable-plus/dist/vue-draggable-plus.iife.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/vue/dist/vue.runtime.esm-browser.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/vue/dist/vue.runtime.esm-browser.prod.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/sortablejs/modular/sortable.esm.js").pipe(gulp.dest('./web/npm/'));
}
function taskBuildJsMain() {
return gulp.src(main_js_files)
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/'));
}
function taskBuildDatetimepicker() {
return gulp.src(["web_src/js/bootstrap-datetimepicker.js"])
.pipe(sourcemaps.init())
.pipe(concat('bootstrap-datetimepicker.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/'));
}
const taskBuildJs = gulp.parallel(taskBuildJsMain, taskBuildDatetimepicker);
/**
* @see https://sass-lang.com/documentation/js-api/interfaces/options/
* @type {import('sass').Options<sync>}
*/
const sassOptions = {
style: 'compressed',
loadPaths: ['web/'],
quietDeps: true,
silenceDeprecations: ['color-functions', 'import', 'global-builtin'],
};
function taskBuildCss() {
return gulp.src("web/css/*.scss")
.pipe(sourcemaps.init())
.pipe(sass.sync(sassOptions).on('error', sass.logError))
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/css/'));
}
function taskBuildPluginCss() {
return gulp.src("plugins/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass.sync(sassOptions).on('error', sass.logError))
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('plugins/'));
}
function taskBuildHtml2PdfCss() {
return gulp.src("assets/html2pdf/*.scss")
.pipe(sourcemaps.init())
.pipe(sass.sync(sassOptions).on('error', sass.logError))
.pipe(postcss([autoprefixer()]))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('assets/html2pdf/'));
}
function taskWatch() {
gulp.watch(main_js_files, {usePolling: true}, taskBuildJs);
gulp.watch(["web_src/js/bootstrap-datetimepicker.js"], {usePolling: true}, taskBuildDatetimepicker);
gulp.watch(["web/css/*.scss"], {usePolling: true}, gulp.parallel(taskBuildCss, taskBuildPluginCss));
gulp.watch(["plugins/**/*.scss"], {usePolling: true}, taskBuildPluginCss);
gulp.watch(["assets/html2pdf/*.scss"], {usePolling: true}, taskBuildHtml2PdfCss);
gulp.watch(['web_src/js/vue/**/*.vue'], taskCompileVue);
}
function taskCompileVue() {
return gulp
.src('web_src/js/vue/**/*.vue')
.pipe(createVueTransform('/npm/vue.runtime.esm-browser.prod.js'))
.pipe(terser())
.pipe(gulp.dest('web/js/vue/'));
}
gulp.task('build-js', taskBuildJs);
gulp.task('build-css', taskBuildCss);
gulp.task('build-html2pdf-css', taskBuildHtml2PdfCss);
gulp.task('build-plugin-css', taskBuildPluginCss);
gulp.task('build-plugin-vue', taskCompileVue);
gulp.task('copy-files', taskCopyFiles);
gulp.task('watch', taskWatch);
gulp.task('default', gulp.parallel(taskBuildJs, taskCompileVue, taskBuildCss, taskCopyFiles, taskBuildPluginCss, taskBuildHtml2PdfCss));