-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
93 lines (78 loc) · 2.03 KB
/
gulpfile.babel.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
'use strict'; // eslint-disable-line
import gulp from 'gulp';
import sass from 'gulp-sass';
import babel from 'gulp-babel';
import prefix from 'gulp-autoprefixer';
// import uglify from 'gulp-uglify';
import sourcemaps from 'gulp-sourcemaps';
import nodemon from 'gulp-nodemon';
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/*.html').pipe(gulp.dest('dist')));
gulp.task('js', () =>
gulp
.src('app/js/*.js')
.pipe(
babel({
presets: ['env'],
}),
)
.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,
});
});