-
Notifications
You must be signed in to change notification settings - Fork 25
/
gulpfile.js
187 lines (167 loc) · 6.99 KB
/
gulpfile.js
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
'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 ts from 'gulp-typescript';
// SASS
import * as dartSass from 'sass';
import gulpSass from 'gulp-sass';
const sass = gulpSass(dartSass);
const tsProject = ts.createProject('tsconfig.json');
const main_js_files = [
"node_modules/bootstrap/dist/js/bootstrap.js",
"node_modules/bootbox/bootbox.all.js",
"web/js/scrollintoview.js",
"web/js/jquery.isonscreen.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/corejs-typeahead/dist/typeahead.bundle.min.js").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/jquery/dist/jquery.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/requirejs/require.js").pipe(terser()).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/dist/vue.global.prod.js").pipe(gulp.dest('./web/npm/'));
await gulp.src("node_modules/vuedraggable/dist/vuedraggable.umd.min.js").pipe(gulp.dest('./web/npm/'));
}
function taskBuildTypescript() {
return gulp.src('web/typescript/**/*.ts')
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('web/js/build/'));
}
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/build/'));
}
function taskBuildDatetimepicker() {
return gulp.src(["web/js/bootstrap-datetimepicker.js"])
.pipe(sourcemaps.init())
.pipe(concat('bootstrap-datetimepicker.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsDe() {
return gulp.src(["web/js/antragsgruen-de.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-de.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsFr() {
return gulp.src(["web/js/antragsgruen-fr.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-fr.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsNl() {
return gulp.src(["web/js/antragsgruen-nl.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-nl.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsCa() {
return gulp.src(["web/js/antragsgruen-ca.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-ca.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsMe() {
return gulp.src(["web/js/antragsgruen-me.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-me.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsEn() {
return gulp.src(["web/js/antragsgruen-en.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-en.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
function taskBuildJsEnGb() {
return gulp.src(["web/js/antragsgruen-en-gb.js"])
.pipe(sourcemaps.init())
.pipe(concat('antragsgruen-en-gb.min.js'))
.pipe(terser())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./web/js/build/'));
}
const taskBuildJs = gulp.parallel(taskBuildJsMain, taskBuildJsDe, taskBuildJsFr, taskBuildJsNl, taskBuildJsCa, taskBuildJsMe, taskBuildJsEn, taskBuildJsEnGb, taskBuildDatetimepicker);
/**
* Gulp-sass does not yet support new API.
* @see https://github.com/dlmanning/gulp-sass/pull/846
* @type {import('sass').LegacyOptions<sync>}
* // @type {import('sass').Options<sync>}
*/
const sassOptions = {
outputStyle: 'compressed',
includePaths: ['web/'],
silenceDeprecations: ['mixed-decls', 'legacy-js-api','color-functions'],
};
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/js/antragsgruen-de.js", "web/js/antragsgruen-en.js", "web/js/antragsgruen-en-gb.js"], {usePolling: true}, taskBuildJs);
gulp.watch(["web/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/typescript/**/*.ts'], {usePolling: true}, taskBuildTypescript);
}
gulp.task('build-js', taskBuildJs);
gulp.task('build-typescript', taskBuildTypescript);
gulp.task('build-css', taskBuildCss);
gulp.task('build-html2pdf-css', taskBuildHtml2PdfCss);
gulp.task('build-plugin-css', taskBuildPluginCss);
gulp.task('copy-files', taskCopyFiles);
gulp.task('watch', taskWatch);
gulp.task('default', gulp.parallel(taskBuildJs, taskBuildTypescript, taskBuildCss, taskCopyFiles, taskBuildPluginCss, taskBuildHtml2PdfCss));