This repository has been archived by the owner on Jul 4, 2019. It is now read-only.
forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
146 lines (130 loc) · 4.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Special thanks to oscar-g (https://github.com/oscar-g) for starting this at https://github.com/oscar-g/patternlab-node/tree/dev-gulp
var pkg = require('./package.json'),
gulp = require('gulp'),
eol = require('os').EOL,
del = require('del'),
strip_banner = require('gulp-strip-banner'),
header = require('gulp-header'),
nodeunit = require('gulp-nodeunit'),
//sass = require('gulp-sass'),
browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
require('gulp-load')(gulp);
var banner = [ '/** ',
' * <%= pkg.name %> - v<%= pkg.version %> - <%= today %>',
' * ',
' * <%= pkg.author %>, and the web community.',
' * Licensed under the <%= pkg.license %> license.',
' * ',
' * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.',
' * ', ' **/'].join(eol);
//load patternlab-node tasks
gulp.loadTasks(__dirname+'/builder/patternlab_gulp.js');
//clean patterns dir
gulp.task('clean', function(cb){
del.sync(['./public/patterns/*'], {force: true});
cb();
})
//build the banner
gulp.task('banner', function(){
return gulp.src([
'./builder/patternlab.js',
'./builder/object_factory.js',
'./builder/lineage_hunter.js',
'./builder/media_hunter.js',
'./builder/patternlab_grunt.js',
'./builder/patternlab_gulp.js',
'./builder/parameter_hunter.js',
'./builder/pattern_exporter.js',
'./builder/pattern_assembler.js',
'./builder/pseudopattern_hunter.js',
'./builder/list_item_hunter.js',
'./builder/style_modifier_hunter.js'
])
.pipe(strip_banner())
.pipe(header( banner, {
pkg : pkg,
today : new Date().getFullYear() }
))
.pipe(gulp.dest('./builder'));
})
//copy tasks
gulp.task('cp:js', function(){
return gulp.src('**/*.js', {cwd:'./source/js'})
.pipe(gulp.dest('./public/js'))
});
gulp.task('cp:img', function(){
return gulp.src(
[ '**/*.gif', '**/*.png', '**/*.jpg', '**/*.jpeg' ],
{cwd:'./source/images'} )
.pipe(gulp.dest('./public/images'))
});
gulp.task('cp:font', function(){
return gulp.src('*', {cwd:'./source/fonts'})
.pipe(gulp.dest('./public/fonts'))
});
gulp.task('cp:data', function(){
return gulp.src('annotations.js', {cwd:'./source/_data'})
.pipe(gulp.dest('./public/data'))
})
gulp.task('cp:css', function(){
return gulp.src('./source/css/style.css')
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream());
})
//server and watch tasks
gulp.task('connect', ['lab'], function(){
browserSync.init({
server: {
baseDir: './public/'
}
});
gulp.watch('./source/css/style.css', ['cp:css']);
//suggested watches if you use scss
gulp.watch('./source/css/**/*.scss', ['sass:style']);
gulp.watch('./public/styleguide/*.scss', ['sass:styleguide']);
gulp.watch([
'./source/_patterns/**/*.mustache',
'./source/_patterns/**/*.json',
'./source/_data/*.json' ],
['lab-pipe'], function(){
browserSync.reload();
});
})
//unit test
gulp.task('nodeunit', function(){
return gulp.src('./test/**/*_tests.js')
.pipe(nodeunit());
})
//sass tasks, turn on if you want to use
gulp.task('sass:style', function(){
return gulp.src('./source/css/*.scss')
.pipe(sass({
outputStyle: 'expanded',
precision: 8
}))
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream());
})
gulp.task('sass:styleguide', function(){
return gulp.src('./public/styleguide/css/*.scss')
.pipe(sass({
outputStyle: 'expanded',
precision: 8
}))
.pipe(gulp.dest('./public/styleguide/css'))
.pipe(browserSync.stream());
})
gulp.task('lab-pipe', ['lab'], function(cb){
cb();
browserSync.reload();
})
gulp.task('default', ['lab']);
gulp.task('assets', ['cp:js', 'cp:img', 'cp:font', 'cp:data', 'sass:style', 'sass:styleguide']);
gulp.task('prelab', ['clean', 'banner', 'assets']);
gulp.task('lab', ['prelab', 'patternlab'], function(cb){cb();});
gulp.task('patterns', ['patternlab:only_patterns']);
gulp.task('serve', ['lab', 'connect']);
gulp.task('travis', ['lab', 'nodeunit']);
gulp.task('version', ['patternlab:version']);
gulp.task('help', ['patternlab:help']);