-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
101 lines (88 loc) · 2.67 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
// Include gulp
var gulp = require('gulp');
// Include plugins
var concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
cssnano = require('gulp-cssnano'),
svgmin = require('gulp-svgmin'),
autoprefixer = require('gulp-autoprefixer'),
shell = require('gulp-shell'),
uglify = require('gulp-uglify'),
babel = require('gulp-babel'),
replace = require('gulp-replace'),
browserSync = require('browser-sync').create();
// Custom folder variables //////////////////////////////////////
var folderSrc = 'public/src/',
folderDist = 'public/dist/';
gulp.task('sass', function() {
return gulp.src([
'node_modules/normalize.css/normalize.css',
'public/src/styles/custom.scss'
])
.pipe(concat('all-styles.scss'))
.pipe(sass({style: 'compressed'}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
// .pipe(cssnano())
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest('public/dist/'))
.pipe(browserSync.stream());
});
gulp.task('compileVendorJS',function() {
return gulp.src( [
'node_modules/vue/dist/vue.js',
'node_modules/axios/dist/axios.js'
])
.pipe(concat('all-vendor-scripts.js'))
.pipe(gulp.dest(folderDist))
.pipe(browserSync.stream());
});
gulp.task('compileCustomJS',function() {
return gulp.src(folderSrc + 'js/custom.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest(folderDist))
.pipe(browserSync.stream());
});
gulp.task('startArtisanServer', shell.task([
'php artisan serve --host 0.0.0.0'
]));
gulp.task('svgmin', function () {
return gulp.src('public/src/img/ui/*.*')
.pipe(svgmin())
.pipe(gulp.dest('resources/views/icon-files/'))
});
gulp.task('renameSVGs', function () {
return gulp.src('public/src/img/ui/instruments/*.*')
.pipe(rename(function(path) {
path.extname = ".blade.php"
}))
.pipe(gulp.dest('resources/views/icons/instruments/'))
});
// Static server
gulp.task('browser-sync', function() {
browserSync.init({
open: false,
proxy: "0.0.0.0:8000"
});
});
gulp.task('antiCache', function () {
return gulp.src('resources/views/src/app.blade.php')
.pipe(replace('antiCacheString', Date.now()))
.pipe(gulp.dest('resources/views/dist'));
});
gulp.task('watch', function() {
gulp.watch('public/src/js/**', ['compileCustomJS', 'antiCache']);
gulp.watch('public/src/styles/**', ['sass', 'antiCache']);
gulp.watch('public/src/img/ui/**', ['svgmin']);
gulp.watch("*.html").on('change', browserSync.reload, ['antiCache']);
});
// Default Task
gulp.task('default', ['startArtisanServer', 'browser-sync', 'compileCustomJS', 'compileVendorJS', 'antiCache', 'sass', 'svgmin', 'watch']);