This repository has been archived by the owner on May 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
150 lines (123 loc) · 3.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// generated on 2016-09-19 using generator-webapp 2.1.0
const gulp = require('gulp');
const del = require('del');
const wiredep = require('wiredep').stream;
const gulpLoadPlugins = require('gulp-load-plugins');
const $ = gulpLoadPlugins();
const mainBowerFiles = require('main-bower-files')
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const connect = require('gulp-connect-php');
// Error Alerts
function errorAlert(error){
$.notify.onError({
title: "Error compiling file",
message: 'Check your terminal.',
sound: "Sosumi"
})(error); //Error Notification
console.log(error);
this.emit("end"); //End function
};
gulp.task("copy-php", function () {
return gulp.src(paths.pages)
.pipe(gulp.dest("dist"));
});
gulp.task('scripts', () => {
return gulp.src('app/src/scripts/**/*.coffee')
.pipe($.concat('app.coffee'))
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.coffee())
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist/scripts'))
.pipe(browserSync.stream());
});
gulp.task('styles', () => {
gulp.src('app/src/styles/*.scss')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['> 1%', 'last 2 versions', 'Firefox ESR']}))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('dist/styles'))
.pipe(browserSync.stream());
});
gulp.task('images', () => {
return gulp.src('app/src/images/**/*')
.pipe($.cache($.imagemin({
progressive: true,
interlaced: true,
// don't remove IDs from SVGs, they are often used
// as hooks for embedding and styling
svgoPlugins: [{cleanupIDs: false}]
})))
.pipe(gulp.dest('dist/images'));
});
gulp.task('vendor', () => {
// Vendor.js
gulp.src(mainBowerFiles('**/*.js'))
.pipe($.plumber({errorHandler: errorAlert}))
.pipe($.concat('vendor.js'))
.pipe(gulp.dest('dist/scripts'));
// Vendor.css
gulp.src(mainBowerFiles('**/*.css'))
.pipe($.plumber({errorHandler: errorAlert}))
.pipe($.concat('vendor.css'))
.pipe(gulp.dest('dist/styles/'));
});
gulp.task('extras', () => {
return gulp.src([
'app/*.*',
'!app/*.php'
], {
dot: true
}).pipe(gulp.dest('dist'));
});
gulp.task('clean', del.bind(null, ['.tmp', 'dist', 'build']));
// inject bower components
gulp.task('wiredep', () => {
gulp.src('app/src/styles/*.scss')
.pipe(wiredep({
ignorePath: /^(\.\.\/)+/
}))
.pipe(gulp.dest('app/src/styles'));
gulp.src('app/**/*.php')
.pipe(wiredep({
exclude: ['bootstrap-sass'],
ignorePath: /^(\.\.\/)*\.\./
}))
.pipe(gulp.dest('app'));
});
gulp.task('browser-sync', function() {
connect.server({ port: 8010, keepalive: true}, function (){
browserSync({
proxy: '127.0.0.1:8010',
port: 8080,
open: true,
});
});
});
gulp.task('serve', ['make', 'browser-sync'], () => {
gulp.watch('app/src/styles/*.scss', ['styles']);
gulp.watch('app/src/scripts/**/*.coffee', ['scripts']);
gulp.watch('app/src/images/**/*', ['images']);
gulp.watch("app/**/*.php").on('change', browserSync.reload);
});
gulp.task('build', ['make'], () => {
gulp.src(['app/**', '!app/{src,src/**}'])
.pipe(gulp.dest('build/app'));
gulp.src(['dist/**/*'])
.pipe(gulp.dest('build/dist'));
gulp.src('*.php')
.pipe(gulp.dest('build'));
gulp.src('./vendor/**/*.php')
.pipe(gulp.dest('build/vendor'));
});
gulp.task('make', ['styles', 'scripts', 'images', 'vendor', 'extras']), () => {
console.log('Files compiled');
};
gulp.task('default', ['serve'], () => {});