-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.61 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
'use strict';
const gulp = require('gulp'),
del = require('del'),
config = require('./config'),
webpack = require('webpack-stream'),
browserSync = require('browser-sync').create();
gulp.task('browser-sync', function() {
browserSync.init({
ghostMode: false,
proxy: config.previewURL,
notify: false
});
});
gulp.task('webpack', function() {
return gulp.src(config.scripts.entry)
.pipe(webpack(require('./webpack.config.js'), null, function(err, stats) {
if(err) {
console.log(err.toString());
}
if(config.webpack_stats) {
console.log(stats.toString());
}
}))
.pipe(gulp.dest(config.scripts.main_DIR));
});
gulp.task('webpackStyles', function() {
return gulp.src(config.scss.src_DIR + config.scss.src)
.pipe(webpack(require('./webpack.style.config.js'), null, function(err, stats) {
if(err) {
console.log(err.toString());
}
if(config.webpack_stats) {
console.log(stats.toString());
}
}))
.pipe(gulp.dest(config.scss.dest_DIR));
});
gulp.task('loadStyles', ['webpackStyles'], function() {
del([config.scss.dest_DIR + 'style.js']);
return gulp.src(config.scss.dest_DIR + config.scss.outputName)
.pipe(browserSync.stream());
});
gulp.task('loadScripts', ['webpack'], function() {
browserSync.reload();
});
gulp.task('watch', ['browser-sync'], function() {
gulp.watch('./**/*.php', function() {
browserSync.reload();
});
gulp.watch(config.scss.src_DIR + '**/*.scss', ['loadStyles']);
gulp.watch([config.scripts.modules_DIR + "*.js", config.scripts.entry], ['loadScripts']);
});
gulp.task('default', ['browser-sync', 'loadScripts', 'loadStyles']);