This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
132 lines (118 loc) · 2.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
// Dependencies
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));
var notify = require('gulp-notify');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var uglify = require('gulp-uglify');
var saveLicense = require('uglify-save-license');
// Path Configs
var config = {
sassPath: './sass',
cssPath: '.',
npmPath: './node_modules',
globalsPath: './node_modules/globals/g/4'
}
/**
* Sass Configurations
*
* Dev and Prod configuration profiles for sass
*
**/
// Production
var sassOptions = {
outputStyle: 'compressed',
sourceComments: false,
includePaths: [
config.npmPath + '/bootstrap/scss',
config.npmPath + '/@fortawesome/fontawesome-free/scss',
config.sassPath
],
precision: 10
}
//Dev
var sassDevOptions = {
outputStyle: 'expanded',
sourceComments: true,
includePaths: [
config.npmPath + '/bootstrap/scss',
config.npmPath + '/@fortawesome/fontawesome-free/scss',
config.sassPath
],
precision: 10
}
/**
* Uglify Options
*
* Tell uglify to keep certiain comments, etc
*
**/
var uglifyOptions = {
output: {
comments: saveLicense
}
}
/**
* Sass Compilers
*
* Dev and Prod compilers
*
**/
gulp.task('sass-dev', function() {
return gulp
.src(config.sassPath + '/style.scss')
.pipe(sourcemaps.init())
.pipe(sass(sassDevOptions).on('error', notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.cssPath));
});
gulp.task('editor-sass-dev', function() {
return gulp
.src(config.sassPath + '/block-editor.scss')
.pipe(sourcemaps.init())
.pipe(sass(sassDevOptions).on('error', notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'));
});
gulp.task('sass', function() {
return gulp
.src(config.sassPath + '/style.scss')
.pipe(sass(sassOptions).on('error', notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(autoprefixer())
.pipe(gulp.dest(config.cssPath));
});
gulp.task('editor-sass', function() {
return gulp
.src(config.sassPath + '/block-editor.scss')
.pipe(sass(sassOptions).on('error', notify.onError(function (error) {
return "Error: " + error.message;
})))
.pipe(autoprefixer())
.pipe(gulp.dest('./css'));
});
// Watch function (sass) - dev use only
gulp.task('watch',function() {
gulp
.watch(config.sassPath + '/**/*.scss', gulp.parallel(
'sass-dev',
'editor-sass-dev'
));
});
// Dev - full dev build
gulp.task('dev', gulp.parallel(
'sass-dev',
'editor-sass-dev'
));
// Default - full production build
gulp.task('default', gulp.parallel(
'sass',
'editor-sass'
));