-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathgulpfile.js
118 lines (104 loc) · 4.66 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
/*******************************************************************************
1. DEPENDENCIES
*******************************************************************************/
var gulp = require('gulp'); // gulp core
var compass = require('gulp-compass'); // compass compiler
var uglify = require('gulp-uglify'); // uglifies the js
var jshint = require('gulp-jshint'); // check if js is ok
var rename = require("gulp-rename"); // rename files
var concat = require('gulp-concat'); // concatinate js
var notify = require('gulp-notify'); // send notifications to osx
var plumber = require('gulp-plumber'); // disable interuption
var stylish = require('jshint-stylish'); // make errors look good in shell
var minifycss = require('gulp-minify-css'); // minify the css files
var browserSync = require('browser-sync').create(); // inject code to all devices
var autoprefixer = require('gulp-autoprefixer'); // sets missing browserprefixes
var nodemon = require('gulp-nodemon');
var webpack = require('webpack');
var webpackStream = require('webpack-stream');
var port = process.env.PORT || 3000;
/*******************************************************************************
2. FILE DESTINATIONS (RELATIVE TO ASSSETS FOLDER)
*******************************************************************************/
var target = {
sass_src : 'css/scss/**/*.scss', // all sass files
css_dest : 'public/css', // where to put minified css
css_output : 'public/css/*.css', // where to put minified css
sass_folder : 'css/scss', // where to put minified css
js_concat_src : [ // all js files that should be concatinated
'src/utils.js',
'src/store.js',
'src/winner-service.js',
'src/score-view.js',
'src/grid-view.js',
'src/fiveicon-view.js',
'src/game.js',
'src/initializer.js'
],
js_dest : 'public/js', // where to put minified js
css_img : 'public/css/i'
};
/*******************************************************************************
3. COMPASS TASK
*******************************************************************************/
gulp.task('compass', function() {
gulp.src(target.sass_src)
.pipe(plumber())
.pipe(compass({
css: target.css_dest,
sass: target.sass_folder,
image: target.css_img
}))
.pipe(autoprefixer(
'last 2 version',
'> 1%',
'ios 6',
'android 4'
))
.pipe(minifycss())
.pipe(gulp.dest(target.css_dest));
});
/*******************************************************************************
4. JS TASKS
*******************************************************************************/
// lint my custom js
gulp.task('js-lint', function() {
gulp.src(target.js_concat_src) // get the files
.pipe(jshint()) // lint the files
.pipe(jshint.reporter(stylish)) // present the results in a beautiful way
});
/*******************************************************************************
5. BROWSER SYNC
*******************************************************************************/
gulp.task('browser-sync', function() {
browserSync.init({
proxy: 'http://localhost:' + port,
files: ['public/**/*.*'],
port: 5000
});
});
// Reference: https://gist.github.com/sogko/b53d33d4f3b40d3b4b2e
gulp.task('nodemon', function(cb) {
return nodemon({
script: 'index.js'
}).once('start', cb);
});
gulp.task('webpack', function() {
return gulp.src(target.js_concat_src)
.pipe(webpackStream({
output: {
filename: 'app.js'
}
}))
.pipe(gulp.dest(target.js_dest));
});
/*******************************************************************************
1. GULP TASKS
*******************************************************************************/
// gulp.task('watch', function() {
// gulp.watch(target.sass_src, ['compass']).on('change', browserSync.reload);
// gulp.watch(target.css_output).on('change', browserSync.reload);
// gulp.watch(target.js_concat_src, ['js-lint']).on('change', browserSync.reload);
// gulp.watch(target.js_concat_src, ['webpack']).on('change', browserSync.reload);
// });
gulp.task('default', ['compass', 'js-lint', 'webpack', 'nodemon']);