-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·103 lines (93 loc) · 3.43 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
'use strict';
/*------------------------------------------------------------------------------
* Include modules
------------------------------------------------------------------------------*/
require('./src/gulp/install.js');
require('./src/gulp/pug.js');
require('./src/gulp/slim.js');
require('./src/gulp/bundlejs.js');
require('./src/gulp/image.js');
require('./src/gulp/tasks.js');
var $ = [];
var argv = require('yargs').argv;
var browserSync = require('browser-sync').create();
var gulp = require('gulp');
var opt = require('./src/gulp/config.js').opt;
var paths = require('./src/gulp/config.js').paths;
var nodeSassConf = require('./src/gulp/config.js').nodeSassConf;
$.autoprefixer = require('gulp-autoprefixer');
$.cssGlobbing = require('gulp-css-globbing');
$.minifyCss = require('gulp-clean-css');
$.sass = require('gulp-sass');
$.sourcemaps = require('gulp-sourcemaps');
/*------------------------------------------------------------------------------
* sass Tasks
------------------------------------------------------------------------------*/
switch(opt.cssBase) {
case 'foundation':
nodeSassConf.includePaths.push(paths.srcBower + 'foundation/scss');
break;
case 'bootstrap':
nodeSassConf.includePaths.push(paths.srcBower + 'bootstrap-sass-official/assets/stylesheets');
break;
}
gulp.task('sass:node', function() {
return gulp.src(paths.srcScss + '*.scss')
.pipe($.sourcemaps.init())
.pipe($.cssGlobbing({ extensions: ['.scss'] }))
.pipe($.sass(nodeSassConf).on('error', $.sass.logError))
.pipe($.autoprefixer({
browsers: ['> 1%', 'last 2 versions', 'ie 10', 'ie 9'],
cascade: false
}))
.pipe($.minifyCss())
.pipe($.sourcemaps.write('maps', {
includeContent: false,
sourceRoot: paths.srcScss
}))
.pipe(gulp.dest(paths.destCss))
.pipe(browserSync.stream({ match: '**/*.css' }));
});
/*------------------------------------------------------------------------------
* browser-sync
------------------------------------------------------------------------------*/
gulp.task('slim:bs', ['slim'], function() {
browserSync.reload();
return;
});
gulp.task('pug:bs', ['pug'], function() {
browserSync.reload();
return;
});
gulp.task('js:bs', ['js:browserify'], function() {
browserSync.reload();
return;
});
gulp.task('sprite:bs', ['sprite'], function() {
browserSync.reload();
return;
});
gulp.task('inline-svg:bs', ['sprite:inline-svg'], function() {
browserSync.reload();
return;
});
gulp.task('browser-sync', function() {
var args = {};
if (argv.mode == 'server' ) {
args.server = { baseDir: paths.root };
args.startPath = paths.htmlDir;
} else {
args.proxy = opt.proxy;
args.open = 'external';
}
if (opt.tunnel != false) args.tunnel = opt.tunnel;
args.browser = opt.browser;
browserSync.init(args);
gulp.watch([paths.srcSlim + '**/*.slim'], { interval: 500 }, ['slim:bs']);
gulp.watch([paths.srcPug + '**/*.pug'], { interval: 500 }, ['pug:bs']);
gulp.watch([paths.srcJs + '**/*.js'], { interval: 500 }, ['js:bs']);
gulp.watch([paths.srcScss + '**/*.scss'], { interval: 500 }, ['sass:node']);
gulp.watch([paths.srcImg + 'sprite/**/*.png'], { interval: 500 }, ['sprite:bs']);
gulp.watch([paths.srcImg + 'sprite-svg/**/*.svg'], { interval: 500 }, ['inline-svg:bs']);
gulp.watch([paths.reloadOnly], { interval: 500 }).on('change', browserSync.reload);
});