forked from TodayDesign/megatype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
115 lines (98 loc) · 3.4 KB
/
gulpfile.babel.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
import gulp from 'gulp';
import del from 'del';
import gulpLoadPlugins from 'gulp-load-plugins';
import connect from 'connect';
import serveStatic from 'serve-static';
import http from 'http';
const $ = gulpLoadPlugins({
pattern: ['gulp-*', 'gulp.*']
});
var paths = {
styles: 'megatype.scss',
tests: './test'
};
// =======================================================================
// Tests
// =======================================================================
let httpServer;
gulp.task('test:styles', () => {
return gulp
.src(paths.tests + '/fixtures/test.scss')
.pipe(
$.sass({
outputStyle: 'expanded',
precision: 6,
includePaths: [
'./node_modules/susy/sass'
]
})
.on('error', $.sass.logError)
)
.pipe($.postcss([
require('autoprefixer')({browsers: ['last 3 versions', '> 5%', 'IE >= 9']})
]))
.pipe($.groupCssMediaQueries())
.pipe(gulp.dest(paths.tests + '/fixtures'))
.pipe($.size());
});
gulp.task('test:serve', (done) => {
let app = connect().use(serveStatic('test/fixtures'));
httpServer = http.createServer(app).listen(8000, done);
});
gulp.task('test:e2e', ['test:styles', 'test:serve'], () => {
return gulp.src(
'wdio' +
(process.env.NODE_ENV === 'test' ? '-sauce' : '') +
'.conf.js'
).pipe($.webdriver()).on('error', () => {
process.exit(1);
});
});
gulp.task('test', ['test:e2e'], () => {
httpServer.close();
});
// =======================================================================
// Styles: compiles sass, autoprefixes, and combines media queries
// =======================================================================
gulp.task('styles', () => {
return gulp.src(paths.styles)
.pipe($.sass({
outputStyle: 'expanded',
precision: 10,
includePaths: [
'./node_modules',
'./bower_components'
]
})
.on('error', $.sass.logError))
.pipe($.postcss([
require('autoprefixer')({browsers: ['last 3 versions', '> 5%', 'IE >= 9']})
]))
.pipe($.groupCssMediaQueries())
.pipe(gulp.dest('dist'))
.pipe($.size());
});
// =======================================================================
// Build task: builds all files and minifies into 'dist'
// =======================================================================
gulp.task('build', ['styles',], () => {});
// =======================================================================
// Default build
// =======================================================================
gulp.task('default', ['build'], () => {});
// alias
gulp.task('dist', ['build'], () => {});
// =======================================================================
// Development watch task. Does not build anything initially
// =======================================================================
gulp.task('watch', (done) => {
// watch the source files, and build relevant files
gulp.watch([
'./**/*.scss'],
['styles']
);
});
// =======================================================================
// Cleans built files
// =======================================================================
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));