-
Notifications
You must be signed in to change notification settings - Fork 33
/
gulpfile.js
94 lines (84 loc) · 2.3 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
var gulp = require('gulp'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
cleanCSS = require('gulp-clean-css'),
browserify = require('browserify'),
stream = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
pkg = require('./package.json'),
sass = require('gulp-dart-sass'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload
gulp.task('build-sagiri', function () {
return browserify({
entries: 'js/global/sagiri.js',
debug: false,
standalone: 'Sagiri'
})
.transform('browserify-versionify', {
placeholder: '__VERSION__',
version: pkg.version
})
.transform('babelify')
.bundle()
.on('error', function (error) {
console.log(error.toString())
})
.pipe(stream('sagiri.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('js'))
})
gulp.task('build-index', function () {
return browserify({
entries: 'js/modules/index.js',
debug: false
})
.transform('babelify')
.bundle()
.on('error', function (error) {
console.log(error.toString())
})
.pipe(stream('index.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('js'))
})
gulp.task('build-css', function () {
return gulp
.src(['css/mix.css'])
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(cleanCSS({ compatibility: 'ie9', level: 2 }))
.pipe(autoprefixer({ cascade: false }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./css'))
})
gulp.task('build-util', function () {
return gulp
.src(['util/!(*.min).js', 'util/**/!(*.min).js'])
.pipe(babel())
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('util'))
})
gulp.task('start', function () {
browserSync.init({
proxy: 'localhost'
})
gulp.watch(['./*', './**/*']).on('change', reload)
gulp.watch(
['css/!(*.min).css', 'css/**/!(*.min).css', 'css/**/!(*.min).scss'],
gulp.parallel(['build-css'])
)
gulp.watch(
['js/**/!(*.min).js'],
gulp.parallel(['build-index', 'build-sagiri'])
)
gulp.watch(['util/!(*.min).js'], gulp.parallel(['build-util']))
})
gulp.task(
'build',
gulp.parallel(['build-index', 'build-sagiri', 'build-css', 'build-util'])
)