-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
107 lines (85 loc) · 1.95 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var connect = require('gulp-connect');
var openPage = require("gulp-open");
var webpack = require('gulp-webpack');
/**
* HTML
*
* reload html
*/
gulp.task("html", function() {
var stream = gulp.src('*.html')
.pipe(connect.reload());
return stream;
});
/**
* CSS PREPROCESSING
*
* Sass, vender prefix, minify, move
*/
gulp.task('css', function() {
var stream = gulp.src('resources/scss/**/*.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(minifyCSS({ noAdvanced: true }))
.pipe(gulp.dest('resources/css'))
.pipe(connect.reload());
return stream;
});
/**
* WEBPACK
*
* Process javascript modules into common.js format
*/
gulp.task("webpack", function() {
var stream = gulp.src('resources/js/app.js')
.pipe(webpack({
output: {
filename: 'production.js'
}
}))
.pipe(gulp.dest('resources/js/'))
.pipe(connect.reload());
return stream;
});
/**
* WATCH
*
* Rerun process after any of these files are edited
*/
gulp.task('watch', function() {
gulp.watch('resources/scss/**/*.scss', ['css']);
gulp.watch('resources/js/**/*.js', ['webpack']);
gulp.watch('resources/images/**/*.{jpg,png,gif}');
gulp.watch('index.html', ['html']);
});
/**
* CONNECT SERVER
*
* Loads the server locally and reloads when
* connect.reload() is called.
*/
gulp.task('connect', function() {
connect.server({
root: '.',
port: 8000,
livereload: true
});
});
/**
* BUILD TASKS
*
* Local and production build tasks
*/
gulp.task('default', ['css', 'webpack', 'watch', 'connect'], function() {
//Now open in browser
var stream = gulp.src("index.html")
.pipe(openPage("", {
app: "Google Chrome",
url: "http://localhost:8000"
}));
return stream;
});