https-jrtorres042-github-com
/
git_microsoft-powershell_achived-credential_terms-of-service_blog_covid-19_chromium-apis_sdks-diff-1
Public template
forked from GoogleChrome/chromium-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
executable file
·139 lines (125 loc) · 3.27 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
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
'use strict';
const path = require('path');
const gulp = require('gulp');
const babel = require("gulp-babel");
const del = require('del');
const uglifyEs = require('gulp-uglify-es');
const uglify = uglifyEs.default;
const gulpLoadPlugins = require('gulp-load-plugins');
const eslintIfFixed = require('gulp-eslint-if-fixed');
const $ = gulpLoadPlugins();
const rollup = require('rollup');
const rollupResolve = require('rollup-plugin-node-resolve');
const rollupLitCss = require('rollup-plugin-lit-css');
const rollupBabel = require('rollup-plugin-babel');
const rollupMinify = require('rollup-plugin-babel-minify');
function minifyHtml() {
return $.minifyHtml({
quotes: true,
empty: true,
spare: true
}).on('error', console.log.bind(console));
}
function uglifyJS() {
return uglify({
output: {comments: 'some'},
});
}
function license() {
return $.license('Apache2', {
organization: 'Copyright (c) 2016 The Google Inc. All rights reserved.',
tiny: true
});
}
gulp.task('lint', () => {
return gulp.src([
'static/js-src/*.js',
'static/elements/*.js',
])
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('lint-fix', () => {
return gulp.src([
'static/js-src/*.js',
'static/elements/*.js',
], {base: './'})
.pipe($.eslint({fix:true}))
.pipe($.eslint.format())
.pipe(eslintIfFixed('./'))
.pipe($.eslint.failAfterError());
});
// Compile and automatically prefix stylesheets
gulp.task('styles', () => {
const AUTOPREFIXER_BROWSERS = [
'last 1 version',
'last 2 iOS versions'
];
// For best performance, don't add Sass partials to `gulp.src`
return gulp.src([
'static/sass/**/*.scss'
])
.pipe($.sass({
outputStyle: 'compressed',
precision: 10
}).on('error', $.sass.logError))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('static/css'));
});
gulp.task('rollup', () => {
return rollup.rollup({
input: 'static/components.js',
plugins: [
rollupLitCss({include: []}),
rollupResolve(),
rollupBabel({
plugins: ["@babel/plugin-syntax-dynamic-import"]
}),
rollupMinify({comments: false}),
],
}).then(bundle => {
return bundle.write({
dir: 'static/dist',
format: 'es',
sourcemap: true,
compact: true,
});
});
});
// Run scripts through babel.
gulp.task('js', () => {
return gulp.src([
'static/js-src/**/*.js',
])
.pipe(babel()) // Defaults are in .babelrc
.pipe(uglifyJS())
.pipe(license()) // Add license to top.
.pipe($.rename({suffix: '.min'}))
.pipe(gulp.dest('static/js'));
});
// Clean generated files
gulp.task('clean', () => {
return del([
'static/css/',
'static/dist',
'static/js/',
], {dot: true});
});
// Build production files, the default task
gulp.task('default', gulp.series(
'clean',
'styles',
'js',
'lint-fix',
'rollup',
));
// Build production files, the default task
gulp.task('watch', gulp.series(
'default',
function watch() {
gulp.watch(['static/sass/**/*.scss'], gulp.series('styles'));
gulp.watch(['static/js-src/**/*.js', 'static/elements/*.js'], gulp.series(['lint', 'js']));
gulp.watch(['static/components.js', 'static/elements/*.js'], gulp.series(['rollup']));
}
));