forked from mattbanks/Drupal-7-Starter-Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
136 lines (114 loc) · 4.14 KB
/
gulpfile.js
File metadata and controls
136 lines (114 loc) · 4.14 KB
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
133
134
135
136
/*global -$ */
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var eventStream = require('event-stream');
var tsProject = $.typescript.createProject({
declarationFiles: false,
noExternalResolve: true,
sortOutput: true
});
gulp.task('scripts', function() {
var tsResult = gulp.src('src/scripts/ts/**/*.ts')
.pipe($.sourcemaps.init()) // This means sourcemaps will be generated
.pipe($.typescript(tsProject));
return eventStream.merge( // Merge the two output streams, so this task is finished when the IO of both operations are done.
tsResult.dts.pipe(gulp.dest('src/scripts/ts/definitions')),
tsResult.js.pipe(
$.concat('main.js')) // You can use other plugins that also support gulp-sourcemaps
.pipe($.sourcemaps.write()) // Now the sourcemaps are added to the .js file
.pipe(gulp.dest('build/scripts')
)
);
});
// styles task, will run when any SCSS files change & BrowserSync
// will auto-update browsers
gulp.task('styles', function () {
return gulp.src('src/scss/**/*.scss')
.pipe($.sourcemaps.init())
.pipe($.sass({
outputStyle: 'nested', // libsass doesn't support expanded yet
precision: 10,
includePaths: ['.'],
onError: function (err) { notify().write(err); console.error.bind(console, 'Sass error:'+err);}
}))
.pipe($.postcss([
require('autoprefixer-core')({browsers: ['last 2 version']})
]))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('build/css'))
.pipe($.filter('scss**/*.css'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('jshint', function () {
return gulp.src('build/scripts/**/*.js')
.pipe(reload({stream: true, once: true}))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});
gulp.task('images', function () {
return gulp.src('src/images/**/*')
.pipe($.newer('build/'))
.pipe($.cache($.imagemin({
progressive: true,
interlaced: true,
svgoPlugins: [{removeViewBox: false}]
})))
.pipe(gulp.dest('build/images'));
});
gulp.task('fonts', function () {
return gulp.src('src/fonts/**/*')
.pipe($.filter('**/*.{eot,svg,ttf,woff}'))
.pipe(gulp.dest('build/fonts'));
});
gulp.task('extras', function () {
return gulp.src([
'src/*.*',
'src/scripts/vendor/**/*'
], {
base: 'src/',
dot: true
}).pipe(gulp.dest('build'));
});
gulp.task('bs-reload', function (){
browserSync.reload();
});
gulp.task('browser-sync', function(){
//watch files
var files = [
'build/css/**/*.css',
'build/scripts/**/*js',
'build/images/**/*',
'templates/*.tpl.php'
];
return browserSync.init(files, {
proxy: "http://localhost:8888", //change this to whatever your local development URL is.
open: false,
injectChanges: true
});
});
gulp.task('drush', $.shell.task([
"cd ~/.kalabox/kalastack/ && vagrant ssh -c 'cd /var/www/winterspringdesserts; drush status; exit;'"
]));
gulp.task('watch', ['images', 'fonts', 'styles', 'scripts', 'extras', 'browser-sync'],function () {
gulp.watch('src/scripts/ts/**/*.ts', ['scripts']);
gulp.watch('src/scss/**/*.scss', ['styles']);
gulp.watch('images/**/*', ['images']);
gulp.watch('src/scripts/vendor/**/*', ['extras']);
gulp.watch('src/fonts/*', ['fonts']);
//gulp.watch('bower.json', ['wiredep', 'fonts', reload]);
});
gulp.task('clear', function (done) {
return $.cache.clearAll(done);
});
gulp.task('cleanFonts', require('del').bind(null, ['build/fonts']));
gulp.task('clean', require('del').bind(null, ['.tmp', 'build']));
gulp.task('build', ['images', 'fonts', 'styles', 'scripts', 'extras'], function () {
return gulp.src('build/**/*').pipe($.size({title: 'build', gzip: true}));
});
gulp.task('default', ['clear', 'clean'], function () {
gulp.start('build');
});