This repository was archived by the owner on May 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
95 lines (79 loc) · 2.25 KB
/
gulpfile.js
File metadata and controls
95 lines (79 loc) · 2.25 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var less = require('gulp-less');
var uglify = require('gulp-uglify');
var shell = require('gulp-shell');
gulp.task('build:scripts', function() {
gulp.src(['./src/js/**/*.js'])
.pipe(gulp.dest('./dist/js/'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('build:vendor', function(callback) {
return gulp.src([
'./node_modules/phaser/dist/pixi.js',
'./node_modules/phaser/dist/p2.js',
'./node_modules/phaser/dist/phaser-split.js',
])
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('build:styles', function() {
gulp.src(['src/less/**/*.less'])
.pipe(less())
.pipe(gulp.dest('dist/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('build:html', function() {
gulp.src("src/*.html")
.pipe(gulp.dest('dist/'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('build:images', function() {
gulp.src('src/assets/**/*')
.pipe(gulp.dest('dist/assets'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('clean', function() {
gulp.src("src/*.html")
.pipe(gulp.dest('dist/'))
.pipe(browserSync.stream());
});
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./dist/",
},
port: 8000
});
});
gulp.task('scaffold', shell.task([
'mkdir dist',
'mkdir dist/assets',
'mkdir dist/js',
'mkdir dist/css'
]
));
gulp.task('clean', shell.task([
'rm -rf dist/'
]));
gulp.task('watch', function() {
gulp.watch('./src/js/**', function(event) {
gulp.run('build:scripts');
});
gulp.watch('./src/less/**', function(event) {
gulp.run('build:styles');
});
gulp.watch('./src/**/*.html', function(event) {
gulp.run('build:html');
});
gulp.watch('./src/assets/**/*', function(event) {
gulp.run('build:images');
});
});
gulp.task('default', function() {
gulp.run('browser-sync', 'build:vendor', 'build:scripts', 'build:styles', 'build:images', 'build:html', 'watch');
});