-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
70 lines (70 loc) · 2.19 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
'use strict';
/*global require:true*/
/*jshint esversion: 6 */
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var sass = require('gulp-sass');
var sassLint = require('gulp-sass-lint');
const jshint = require('gulp-jshint');
const stylish = require('jshint-stylish');
var gulpCopy = require('gulp-copy');
var replace = require('gulp-replace');
var $ = require('gulp-load-plugins')();
var refresh = require('gulp-refresh');
// provide a paht to node modules
var sassPaths = [
'node_modules'
];
// Copy materialize and tablesaw libraries.
gulp.task('libsrc', function() {
gulp.src([
'node_modules/materialize-css/dist/js/materialize.min.js'
])
.pipe(gulpCopy('js/vendor', { prefix: 4 }));
gulp.src([
'node_modules/tablesaw/dist/stackonly/tablesaw.stackonly.jquery.js'
])
.pipe(gulpCopy('js/lib', { prefix: 4 }));
gulp.src([
'node_modules/tablesaw/dist/tablesaw-init.js'
])
.pipe(gulpCopy('js/lib', { prefix: 3 }));
});
// Rename functions that conflict with jQueryUI; then move to source control folder js/lib
gulp.task('rename', function() {
gulp.src(['js/vendor/materialize.min.js'])
.pipe(replace('fn.autocomplete', 'fn.autocomplete_materialize'))
.pipe(replace('r.autocomplete', 'r.autocomplete_materialize'))
.pipe(replace('fn.tabs', 'fn.tabs_materialize'))
.pipe(replace('.tabs(', '.tabs_materialize('))
.pipe(gulp.dest('js/lib'));
});
gulp.task('sass', function() {
return gulp.src(['scss/**/**.scss'])
.pipe(sassLint({
configFile: 'scss/.sass-lint.yml',
}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
.pipe(sourcemaps.init())
.pipe(sourcemaps.identityMap())
.pipe($.sass({
includePaths: sassPaths
})
.on('error', $.sass.logError))
.pipe($.autoprefixer({
browsers: ['last 2 versions', 'ie >= 9']
}))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('css'))
.pipe(refresh());
});
gulp.task('lint', function() {
return gulp.src(['./js/*.js', '!./js/vendor.all.js'])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('default', ['sass'], function() {
refresh.listen();
gulp.watch(['scss/**/*.scss'], ['sass']);
});