-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·91 lines (80 loc) · 2.55 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·91 lines (80 loc) · 2.55 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
const path = require('path');
const gulp = require('gulp');
const GulpClass = require('classy-gulp');
const config = require('./config/general.config');
/**
* Gulp plugins starting with "gulp-<name>" are loaded automatically under gPlugins.<name>
* You can rename them or call functions on required plugins via options object passed to gulp-load-plugins:
* {
* rename: {},
* postRequireTransforms: {}
* }
* Others are manually appended via the second array.
*/
const gPlugins = {
...require('gulp-load-plugins')(),
...{
browserSync: require('browser-sync').create(),
},
};
class Flow extends GulpClass {
constructor() {
super();
}
defineTasks() {
/**
* All tasks which are accessible via "gulp <taskName>" are defined here.
*/
return {
server: gulp.series(this.startBrowserSync),
build: gulp.parallel(this.styles),
default: gulp.series('build', 'server', this.watch),
};
}
/**
* Compiles general project styles. Vue component-specific styles are handled during js compilation.
*/
styles() {
return gulp.src([path.join(config.paths.sass.src, '/**/*.scss')])
.pipe(gPlugins.plumber())
.pipe(gPlugins.sourcemaps.init())
.pipe(gPlugins.sass(require('./config/nodesass.config')).on('error', gPlugins.sass.logError))
.pipe(gPlugins.autoprefixer({ browsers: ['last 3 versions', '> 1%'] }))
.pipe(gPlugins.sourcemaps.write('.'))
.pipe(gulp.dest(config.paths.sass.dist))
.pipe(gPlugins.browserSync.stream({ match: '**/*.{css|map}' }));
}
/**
* Watches for changes and automatically performs a given task depending on the type of file changed.
*/
watch(done) {
gulp.watch(path.join(config.paths.sass.src, '/**/*.scss'), gulp.series(this.styles, this.reload)); // SCSS recompile & reload
gulp.watch(['app/**/*.php','*.php'], gulp.series(this.reload)); // PHP files change
gulp.watch(path.join(config.paths.js.src, '**/*.js'), gulp.series(this.reload)); // frontend JS
done();
}
/**
* ========= "Utility" classes start =========
*/
/**
* ========= BrowserSync =========
*/
/**
* Starts the browsersync proxy server
*/
startBrowserSync(done) {
gPlugins.browserSync.init(require('./config/browsersync.config'), done);
}
/**
* Reloads the whole page via browsersync
*/
reload(done) {
gPlugins.browserSync.reload();
done();
}
}
/**
* Let's get the party started!
* Don't forget to have fun on this new project! (✿ ◕ ‿ ◕)ᓄ ╰U╯
*/
gulp.registry(new Flow());