-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
113 lines (94 loc) · 2.56 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
'use strict';
/**
* Module dependencies
*/
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-sass'),
path = require('path'),
del = require('del'),
open = require('open'),
hologram = require('gulp-hologram'),
webpack = require('webpack'),
WebpackDevServer = require('webpack-dev-server'),
webpackConfig = require('./webpack.config.js');
gulp.task('webpack', function (callback) {
webpack(webpackConfig, function (err, stats) {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack]', stats.toString({
colors: true
}));
callback();
});
});
gulp.task('webpack-dev-server', function (callback) {
new WebpackDevServer(webpack(webpackConfig), {
contentBase: path.join(__dirname, 'www'),
stats: {
colors: true
}
}).listen(8080, 'localhost', function (err) {
if (err) {
throw new gutil.PluginError('webpack-dev-server', err);
}
var startUrl = 'http://localhost:8080/webpack-dev-server/index.html';
open(startUrl);
gutil.log('[webpack-dev-server]', startUrl);
});
});
gulp.task('clean', function (cb) {
del([
'www/**/*',
'!www/.gitignore'
], {
dot: true
}, cb);
});
gulp.task('clean-all', function (cb) {
del([
'www/**/*',
'!www/.gitignore',
'node_modules',
'public/bower_components'
], {
dot: true
}, cb);
});
gulp.task('hologram', function() {
gulp.src('hologram_config.yml')
.pipe(hologram({logging:true}));
});
gulp.task('ng-docs', [], function () {
var gulpDocs = require('gulp-ngdocs');
return gulp.src('./app/bootstrap.js')
.pipe(gulpDocs.process())
.pipe(gulp.dest('./docs/ngdocs'));
});
gulp.task('styleguide:generate', function() {
return gulp.src('./app/*.scss')
.pipe(styleguide.generate({
title: 'My Styleguide',
server: true,
rootPath: outputPath,
overviewPath: 'README.md'
}))
.pipe(gulp.dest(outputPath));
});
gulp.task('styleguide:applystyles', function() {
return gulp.src('./app/app.scss')
.pipe(sass({
errLogToConsole: true
}))
.pipe(styleguide.applyStyles())
.pipe(gulp.dest(outputPath));
});
gulp.task('install', ['webpack']);
gulp.task('watch', ['webpack-dev-server', 'ng-docs'], function () {
// Start watching changes and update styleguide whenever changes are detected
// Styleguide automatically detects existing server instance
gulp.watch(['*.scss'], ['styleguide']);
});
gulp.task('styleguide', ['styleguide:generate', 'styleguide:applystyles']);
gulp.task('default', ['install']);