-
Notifications
You must be signed in to change notification settings - Fork 377
/
gulpfile.babel.js
executable file
·106 lines (96 loc) · 2.76 KB
/
gulpfile.babel.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
'use strict';
import rollupResolve from '@rollup/plugin-node-resolve';
import {deleteAsync} from 'del';
import gulp from 'gulp';
import autoPrefixer from 'gulp-autoprefixer';
import babel from 'gulp-babel';
import concat from 'gulp-concat';
import license from 'gulp-license';
import rename from 'gulp-rename';
import uglifyEs from 'gulp-uglify-es';
import {rollup} from 'rollup';
import rollupMinify from 'rollup-plugin-babel-minify';
const uglify = uglifyEs.default;
function uglifyJS() {
return uglify({
output: {comments: 'some'},
});
}
function addLicense() {
return license('Apache2', {
organization: 'Copyright (c) 2024 The Google Inc. All rights reserved.',
tiny: true
});
}
function rollupIgnoreUndefinedWarning(warning, warn) {
// There is currently a warning when using the es6 module from openapi.
// It is a common issue and can be suppresed.
// The error that is suppresed:
// The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
// https://github.com/rollup/rollup/issues/1518#issuecomment-321875784
// Suppres that error but continue to print the remaining errors.
if (warning.code === 'THIS_IS_UNDEFINED') return;
warn(warning); // this requires Rollup 0.46
}
gulp.task('css', () => {
return gulp.src([
'node_modules/@shoelace-style/shoelace/dist/themes/light.css',
])
.pipe(concat('base.css'))
.pipe(gulp.dest('static/css'));
});
gulp.task('rollup', () => {
return rollup({
input: [
'build/components.js',
'build/js-src/openapi-client.js',
'build/js-src/cs-client.js',
'build/js-src/features-page.js',
'build/js-src/shared.js',
],
plugins: [
rollupResolve(),
rollupMinify({mangle: false, comments: false}),
],
onwarn: rollupIgnoreUndefinedWarning,
}).then(bundle => {
return bundle.write({
dir: 'static/dist',
format: 'es',
sourcemap: true,
compact: true,
});
});
});
// Clean generated files
gulp.task('clean', () => {
return deleteAsync([
'static/dist',
], {dot: true});
});
// Build production files, the default task
gulp.task('default', gulp.series(
'clean',
'css',
'rollup',
));
// Build production files, the default task
gulp.task('watch', gulp.series(
'default',
() => {
gulp.watch(['client-src/sass/**/*.scss'], gulp.series('styles'));
gulp.watch([
'client-src/js-src/**/*.js',
'client-src/elements/*.js',
'client-src/elements/*.ts',
'client-src/elements/css/**/*.js',
'client-src/contexts/*.js',
], gulp.series(['js']));
gulp.watch([
'client-src/components.js',
'client-src/elements/*.js',
'client-src/elements/css/**/*.js',
'client-src/contexts/*.js',
], gulp.series(['rollup']));
},
));