-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
89 lines (74 loc) · 2.2 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
'use strict';
const { src, series, dest, parallel, watch, task } = require('gulp');
const cleanCSS = require('gulp-clean-css');
const sass = require('gulp-sass');
const gulpStylelint = require('gulp-stylelint');
const concat = require('gulp-concat');
const eslint = require('gulp-eslint');
sass.compiler = require('node-sass');
// For debugging, make sure gulp is installed
function defaultTask(cb) {
cb();
}
// Compile the theme styles
function themeStyles() {
return src('assets/scss/**/*.scss')
.pipe(sass.sync({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(concat('global.css'))
.pipe(dest('dist/css'));
}
// Lint Theme styles
function lintSassWatch() {
return src('assets/scss/**/*.scss')
.pipe(gulpStylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
}
// Watch Theme style
function watchStyles(done) {
watch('assets/scss/**/*.scss', series(themeStyles, lintSassWatch)),
done();
}
//get the styles from the components library and add them to the theme.
function libraryStyles() {
return src('./node_modules/ucla-bruin-components/public/css/ucla-lib.min.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(dest('dist/css/ucla-components-library'));
}
function lintJavascript() {
return src('assets/js/**/*.js')
.pipe(eslint())
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
//.pipe(eslint.failAfterError());
}
// install bruin component library JS
function libraryConcatJs() {
return src('./node_modules/ucla-bruin-components/public/js/ucla-lib-scripts.min.js')
.pipe(dest('dist/js/ucla-components-library'));
}
// Bundle the js added in the theme.
function themeConcatJs() {
return src('assets/js/**/*.js')
.pipe(concat('scripts.js'))
.pipe(dest('dist/js'));
}
// watch the theme scritps while linting
function watchJavascript(done) {
watch('assets/js/*.js', series(themeConcatJs, lintJavascript));
done();
}
exports.default = defaultTask
exports.production = series(
libraryStyles,
themeStyles,
themeConcatJs,
libraryConcatJs
);
exports.watch = series(
watchStyles,
watchJavascript
);