This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgulpfile.js
91 lines (77 loc) · 2.1 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
'use strict'; // eslint-disable-line
const gulp = require('gulp');
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
const nodemon = require('gulp-nodemon');
const babel = require('gulp-babel');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
gulp.task('copyJS', () =>
gulp
.src(['node_modules/carbon-components/scripts/carbon-components.min.js'])
.pipe(gulp.dest('dist/js'))
);
gulp.task('copyHTML', () => gulp.src('app/views/home.html').pipe(gulp.dest('dist')));
gulp.task('js', () =>
gulp
.src('app/js/*.js')
.pipe(
babel({
presets: ['es2015', 'stage-1'],
})
)
.pipe(gulp.dest('dist/js'))
);
gulp.task('fonts', () =>
gulp
.src('node_modules/carbon-components/src/globals/fonts/*.{woff2,woff}')
.pipe(gulp.dest('app/assets/fonts'))
.pipe(gulp.dest('dist/assets/fonts'))
);
gulp.task('img', () => gulp.src('app/assets/img/**.*').pipe(gulp.dest('dist/assets/img')));
gulp.task('styles', () =>
gulp
.src('app/scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(
sass({
outputStyle: 'compressed',
includePaths: ['node_modules'],
})
)
.pipe(
prefix({
browsers: ['> 1%', 'last 2 versions'],
})
)
.pipe(sourcemaps.write())
.pipe(gulp.dest('./dist/css'))
.pipe(browserSync.stream())
);
gulp.task('nodemon', () => {
let started = false;
const stream = nodemon({
script: './app/bin/www',
watch: './app',
}).on('start', () => {
if (!started) {
started = true;
} else {
browserSync.reload({ stream: false });
}
});
return stream;
});
gulp.task('watch', () => {
gulp.watch('./app/scss/**/*.scss', ['styles', reload]);
gulp.watch('./app/js/*.js', ['js', reload]);
gulp.watch('./app/views/**/*.html', ['copyHTML', reload]);
});
gulp.task('build', ['fonts', 'img', 'styles', 'copyJS', 'copyHTML', 'js']);
gulp.task('dev', ['build', 'watch', 'nodemon'], () => {
browserSync.init({
proxy: 'http://localhost:7777',
open: false,
});
});