-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGulpfile.js
132 lines (113 loc) · 3.05 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
131
132
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
cache = require('gulp-cache'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
minifyCSS = require('gulp-minify-css'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
sass = require('gulp-ruby-sass'),
sequence = require('run-sequence'),
uglify = require('gulp-uglify'),
browserSync = require('browser-sync'),
config = require('./config'),
reload = browserSync.reload,
/**
* If developing this package set to true but make sure you change it to false before
* deploying and re-run gulp
*/
local = true,
destination = 'public/assets/';
/**
* setup stream for package's sass files
* @return gulp object
*/
gulp.task( 'styles', function()
{
var _gulp = gulp.src(config.paths.app.sass)
.pipe( plumber() )
.pipe( sass() )
.pipe( autoprefixer( 'last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4' ) )
.pipe( concat( 'app.bundle.css' ) );
// don't bother with source map rubbish...
if( ! local ) _gulp.pipe( minifyCSS() );
_gulp.pipe( reload({ stream : true } ) );
_gulp.pipe( gulp.dest( destination + 'css' ) );
return _gulp;
});
/**
* setup stream for package's javascript files
* @return gulp object
*/
gulp.task( 'scripts', function()
{
var _gulp = gulp.src(config.paths.app.js)
.pipe( plumber() )
.pipe( concat( 'app.bundle.js' ) );
if( ! local ) _gulp.pipe( uglify() );
_gulp.pipe( gulp.dest( destination + 'js' ) )
_gulp.pipe( reload({ stream : true } ) );
return _gulp;
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task( 'plugin_styles', function()
{
var _gulp = gulp.src(config.paths.plugins.css)
.pipe( plumber() )
.pipe( concat( 'plugins.bundle.css' ) )
.pipe( autoprefixer( 'last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4' ) );
_gulp.pipe( minifyCSS() );
_gulp.pipe( gulp.dest( destination + 'css' ) );
return _gulp;
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task('browser-sync', function() {
browserSync({
proxy: config.domain
});
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task( 'plugin_js', function(){
var _gulp = gulp.src(config.paths.plugins.js)
.pipe( plumber() )
.pipe( concat( 'plugins.bundle.js' ) );
_gulp.pipe( uglify() );
_gulp.pipe( gulp.dest( destination + 'js' ) );
return _gulp;
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task( 'clean', function()
{
return gulp.src([
destination + 'css',
destination + 'js'
], { read: false } )
.pipe( clean({ force : true }) );
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task( 'watch', function () {
gulp.watch( 'scss/**/*.scss', ['styles'] );
gulp.watch( 'javascripts/*.js', ['scripts'] );
});
/**
* [description]
* @return {[type]} [description]
*/
gulp.task( 'default', ['clean','browser-sync'], function() {
sequence( 'styles', 'plugin_styles', 'scripts', 'plugin_js', 'watch' );
});