-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
129 lines (112 loc) · 3.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
var gulp = require('gulp');
var shell = require('gulp-shell');
var connect = require('gulp-connect');
var sass = require('gulp-ruby-sass');
var clipboard = require('gulp-clipboard');
var uglify = require('gulp-uglify');
var uglifycss = require('gulp-uglifycss');
var path = require('path');
var _ = require('lodash');
/** ----------- Build Dir ----------- */
// Alias for path.join
var join = path.join.bind(path);
// Current working directory
var cwd = process.cwd();
// Bower paths
var bower = { path:'./bower_components/' };
_.extend(bower, {
bootstrap: { path: join(bower.path, 'bootstrap-sass/') },
jquery: { path: join(bower.path, 'jquery/') },
prism: { path: join(bower.path, 'prism/') }
});
// Test paths
var test = { path:'test/'};
_.extend(test, {
docs: { path: join(test.path, 'docs/') },
src: { path: join(test.path, 'source/') }
});
_.extend(test.docs, {
css: { path: join(test.docs.path, 'css/') },
js: { path: join(test.docs.path, 'js/') }
});
// Asset paths
var assets = { path:'assets/' };
_.extend(assets, {
css: { path: join(assets.path, 'css/') },
js: { path: join(assets.path, 'js/') }
});
// Doxx commands
var cmd = { source:' --source ', output:' --output ', template: ' --template ', kit: ' --kit ' };
// Doxx commands with path
var source = cmd.source + join(cwd, test.src.path);
var output = cmd.output + join(cwd, test.docs.path);
var template = cmd.template + join(cwd, 'template/index.jade');
var kit = cmd.kit;
cmd = source + output + template + kit;
/** ---------------------- Tasks ---------------------- */
// Task 1: Build the docs
gulp.task('docs',shell.task([
'./node_modules/mr-doc/bin/mr-doc ' + cmd
]));
// Task 2: Build Sass and copy it into the test dir and assets
gulp.task('sass', ['docs'], function() {
return sass("./scss/",{
loadPath:[
join(bower.bootstrap.path, 'assets/stylesheets')
]
})
.on('error', sass.logError)
.pipe(uglifycss({
'max-line-len': 80
}))
.pipe(gulp.dest(test.docs.css.path))
.pipe(gulp.dest(assets.css.path));
});
// Task 3: Copy the files from bower into js and assets
gulp.task('copy:js', ['docs'], function () {
return gulp.src([
bower.prism.path + 'prism.js',
bower.prism.path + 'components/prism-bash.js',
bower.prism.path + 'components/prism-jade.js',
bower.bootstrap.path + 'assets/javascripts/bootstrap/affix.js',
bower.bootstrap.path + 'assets/javascripts/bootstrap/dropdown.js',
bower.bootstrap.path + 'assets/javascripts/bootstrap/scrollspy.js',
bower.bootstrap.path + 'assets/javascripts/bootstrap.min.js',
bower.jquery.path + 'dist/jquery.min.js'
])
.pipe(uglify())
.pipe(clipboard())
.pipe(gulp.dest(test.docs.js.path))
.pipe(gulp.dest(assets.js.path));
});
// Task 4: Copy the files from bower into css
gulp.task('copy:css', ['docs'], function () {
return gulp.src([
bower.prism.path + 'themes/prism.css'
])
.pipe(clipboard())
.pipe(uglifycss({
'max-line-len': 80
}))
.pipe(gulp.dest(test.docs.css.path));
});
// Create server
gulp.task('connect', function() {
connect.server({
root: test.docs.path,
livereload: true
});
});
// Reload the page
gulp.task('html', function () {
gulp.src(test.docs.path + '*.html')
.pipe(connect.reload());
});
// Watch for changes
gulp.task('watch', function () {
gulp.watch(['template/*.jade', 'scss/*.scss', './*.md'], ['docs', 'sass', 'copy:js', 'copy:css']);
});
// Default
gulp.task('default', ['build','connect', 'watch']);
// Build
gulp.task('build', ['docs', 'sass','copy:js', 'copy:css']);