-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
130 lines (110 loc) · 3.31 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
'use strict';
// Require the needed packages
var concat = require( 'gulp-concat' ),
csslint = require( 'gulp-csslint' ),
eslint = require( 'gulp-eslint' ),
gulp = require( 'gulp' ),
jshint = require( 'gulp-jshint' ),
jshintStylish = require( 'jshint-stylish' ),
less = require( 'gulp-less' ),
prefix = require( 'gulp-autoprefixer' ),
minifyCSS = require( 'gulp-minify-css' ),
uglify = require( 'gulp-uglify' ),
tasks = require( 'gulp-task-listing' );
var files = {
//lint : [ 'app.js', 'gulpfile.js', 'js/**/*.js', 'lib/**/*.js' ],
scripts : [
'node_modules/whatwg-fetch/fetch.js',
'node_modules/nunjucks/browser/nunjucks.js',
'node_modules/d3/d3.js',
'assets/scripts/*.js'
],
styles : [ 'assets/less/main.less' ],
watch : {
styles : [ 'assets/less/**/*.less' ]
}
};
/*******************************************************************************
* HELP TASK
*
* This task will list out other available tasks when you run `gulp help`
*/
gulp.task('help', tasks);
/*******************************************************************************
* LINT TASK
*
* This task will lint all JS files for common errors
*/
gulp.task( 'lint', function() {
return gulp.src( files.lint )
.pipe( jshint() )
.pipe( jshint.reporter( jshintStylish ) );
} );
/*******************************************************************************
* STYLE TASK
*
* this task is responsible for the style files
* - we will compile the less files to css
* - we will minify the css files
* - we will run them through autoprefixer
* - and save it to public
*/
gulp.task( 'styles', function () {
return gulp.src( files.styles )
.pipe( less() )
.pipe( csslint( '.csslintrc' ) )
.pipe( csslint.reporter() )
.pipe( prefix( 'last 1 version', '> 1%', 'ie 8', 'ie 7' ) )
.pipe( minifyCSS() )
.pipe( gulp.dest( 'public/' ) );
} );
/*******************************************************************************
* SCRIPT TASKS
*
* this task is responsible for the JavaScript files
* - uglify the js
* - and save it to public
*/
gulp.task( 'scripts', function() {
return gulp.src( files.scripts )
.pipe( eslint() )
.pipe( concat( 'results.js' ) )
.pipe( uglify() )
.pipe( gulp.dest( 'public' ) );
} );
/*******************************************************************************
* BUILD
*
* run all build related tasks with:
*
* $ gulp build
*
*/
gulp.task( 'build', [ 'styles', 'scripts', 'svg' ] );
/*******************************************************************************
* this task will kick off the watcher for JS, CSS, HTML files
* for easy and instant development
*/
gulp.task( 'watch', function() {
//gulp.watch( files.lint, [ 'lint' ] );
gulp.watch( files.watch.styles, [ 'styles' ] );
gulp.watch( files.scripts, [ 'scripts' ] );
} );
/*******************************************************************************
* DEV
*
* run all build related tasks, kick of server at 8080
* and enable file watcher with:
*
* $ gulp dev
*
*/
gulp.task( 'dev', [ 'build', 'watch' ] );
/**
* Default gulp task will run all landingpage task.
* This is just a shorcut for $ gulp landingpage
*
* $ gulp
*
*/
gulp.task( 'default', [ 'help' ] );