-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (71 loc) · 1.81 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
const gulp = require('gulp'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
autoprefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
scss = require('gulp-sass'),
minifyCSS = require('gulp-minify-css'),
streamify = require('gulp-streamify'),
connect = require('gulp-connect'),
inlineSource = require('gulp-inline-source'),
plumber = require('gulp-plumber');
const paths = {
dist : 'dist/',
js : 'src/**/*.js',
scss: 'src/**/*.scss',
style : ['src/style/app.scss'],
mainJs : 'src/app.js',
assetsDir: 'assets/',
assets: 'assets/**/*',
html: 'index.html'
};
/* JS */
gulp.task('js', function() {
browserify({
entries: [paths.mainJs]
})
.bundle()
.pipe(source('app.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest(paths.dist));
});
/* STYLE */
gulp.task('style', function() {
return gulp.src(paths.style)
.pipe(plumber())
.pipe(scss())
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(minifyCSS({processImport: false}))
.pipe(rename('app.css'))
.pipe(gulp.dest(paths.dist));
});
/* WATCH */
gulp.task('watch', function() {
gulp.watch(paths.scss, ['style']);
gulp.watch(paths.js, ['js']);
gulp.watch(paths.html, ['template']);
});
/* TEMPLATE */
gulp.task('template', function() {
return gulp.src(paths.html)
.pipe(inlineSource())
.pipe(gulp.dest(paths.dist));
});
/* CONNECT */
gulp.task('connect', function() {
connect.server({
port: 8888,
root: 'dist'
});
});
/* COPY */
gulp.task('copy', function() {
gulp.src(paths.assets)
.pipe(gulp.dest(paths.dist+'assets/'));
});
/* DEFAULT */
gulp.task('default', ['copy', 'template', 'watch', 'style', 'connect']);
gulp.task('build', ['copy', 'template', 'style']);