-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·105 lines (86 loc) · 2.92 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
/**
* Dependencies
*
*/
'use strict';
// Gulp + plugins
const gulp = require('gulp');
const plugins = require('gulp-load-plugins')();
// Non-gulp modules
plugins.path = require('path');
plugins.browserSync = require('browser-sync');
plugins.eventStream = require('event-stream');
plugins.runSequence = require('run-sequence'); //temporary solution until the release of gulp 4.0
// Shared paths
const paths = {
// Build paths
base: __dirname,
src: plugins.path.join(__dirname, 'source'),
dev: plugins.path.join(__dirname, 'dev'),
devAssets: plugins.path.join(__dirname, 'dev/assets'),
doc: plugins.path.join(__dirname, 'dev/docs'),
helpers: plugins.path.join(__dirname, 'helpers'),
tasks: plugins.path.join(__dirname, 'gulp'),
// Assets
assets: {
css: plugins.path.join(__dirname, 'source/assets/sass'),
js: plugins.path.join(__dirname, 'source/assets/js'),
fonts: plugins.path.join(__dirname, 'source/assets/fonts'),
media: plugins.path.join(__dirname, 'source/assets/media')
},
// HTML templates, Components
html: plugins.path.join(__dirname, 'source/templates'),
components: plugins.path.join(__dirname, 'source/components'),
//Node modules
npm: plugins.path.join(__dirname, 'node_modules'),
};
/**
* Child tasks
*
*/
plugins.getTaskModule = (task) => {
return require(plugins.path.join(paths.tasks, task))(paths, gulp, plugins);
};
gulp.task('css', plugins.getTaskModule('css/sass'));
gulp.task('cssmin', plugins.getTaskModule('css/cssmin'));
gulp.task('watch', plugins.getTaskModule('watch'));
gulp.task('html', plugins.getTaskModule('html/html'));
gulp.task('js', plugins.getTaskModule('js/webpack'));
gulp.task('eslint', plugins.getTaskModule('js/eslint'));
gulp.task('jstest', plugins.getTaskModule('js/karma'));
gulp.task('jsdoc', plugins.getTaskModule('js/jsdoc'));
gulp.task('browser-sync', plugins.getTaskModule('browser-sync'));
gulp.task('copy', plugins.getTaskModule('copy'));
gulp.task('favicon', plugins.getTaskModule('favicon'));
gulp.task('svgsprite', plugins.getTaskModule('media/svgsprite'));
/**
* Utility tasks
*/
// Clean build directory
gulp.task('clean', (fn) => {
return require('del')([
plugins.path.join(paths.dev, '*'),
], fn);
});
/**
* Main tasks
*/
//todo: add style lint
gulp.task('lint', ['eslint']);
gulp.task('test', ['jstest']);
gulp.task('dev', (fn) => {
plugins.util.env.type = 'development';
plugins.runSequence('mainbuild', ['watch', 'browser-sync'], fn);
});
gulp.task('testing', (fn) => {
plugins.util.env.type = 'testing';
plugins.runSequence('mainbuild', ['watch', 'browser-sync'], fn);
});
gulp.task('build', (fn) => {
plugins.util.env.type = 'production';
plugins.runSequence( ['mainbuild'], ['cssmin'], fn);
});
gulp.task('default', ['build']);
gulp.task('mainbuild', ['clean'], (fn) => {
plugins.runSequence( ['copy', 'css', 'eslint', 'js'], ['html', 'jsdoc'], fn);
});