-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·105 lines (84 loc) · 2.37 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
var gulp = require('gulp');
// include plug-ins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
//var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var autoprefixer = require('autoprefixer');
var postcss = require('gulp-postcss');
var sass = require('gulp-sass')(require("sass"));
var sourcemaps = require('gulp-sourcemaps');
var header = require('gulp-header');
// options
var sassOptions = {
errLogToConsole: true,
outputStyle: 'compressed' //expanded, nested, compact, compressed
};
// JS concat, strip debugging and minify
gulp.task('scripts', scripts);
function scripts(done) {
var banner = ['// Gulp compiles scripts and puts them here.',''].join('\n');
gulp.src('./src/js/*.js')
.pipe(jshint(done))
.pipe(jshint.reporter('default'));
gulp.src('./src/js/*.js')
.pipe(concat('scripts.built.js'))
//.pipe(stripDebug())
//.pipe(uglify())
.pipe(header(banner))
.pipe(gulp.dest('./js/'));
done();
// console.log('scripts ran');
}
// CSS concat, auto-prefix and minify
gulp.task('styles', styles);
function styles(done) {
var pkg = require('./package.json');
var banner = ['/*',
'Theme Name: <%= pkg.name %>',
'Theme URI: <%= pkg.homepage %>',
'Author: URI',
'Author URI: https://today.uri.edu',
'Description: Theme for URI websites',
'Version: <%= pkg.version %>',
'License: GNU General Public License v2 or later',
'License URI: http://www.gnu.org/licenses/gpl-2.0.html',
'Text Domain: uri-department',
'Tags: education',
'',
'*/',
'/**',
'@version v<%= pkg.version %>',
'@author <%= pkg.author1 %>',
'@author <%= pkg.author2 %>',
'',
'*/',
''].join('\n')
gulp.src('./src/sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(postcss([ autoprefixer() ]))
.pipe(header(banner, { pkg : pkg } ))
.pipe(sourcemaps.write('./map'))
.pipe(gulp.dest('.'));
done();
//console.log('styles ran');
}
// watch
gulp.task('watcher', watcher);
function watcher(done) {
// watch for JS changes
gulp.watch('./src/js/*.js', scripts);
// watch for CSS changes
gulp.watch('./src/sass/*.scss', styles);
done();
}
gulp.task('default',
gulp.parallel('scripts', 'styles', 'watcher', function(done){
done();
})
);
function done() {
console.log('done');
}