-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (102 loc) · 2.34 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
102
103
104
105
106
107
108
109
110
111
var gulp = require('gulp'),
scss = require('gulp-sass'),
pug = require('gulp-pug'),
plumber = require('gulp-plumber'),
webpack = require('webpack'),
bs = require('browser-sync'),
concat = require('gulp-concat'),
webpackStream = require('webpack-stream'),
notify = require('gulp-notify');
const pathJS = [
'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery-background-video/jquery.background-video.js',
'node_modules/owl.carousel/dist/owl.carousel.min.js'
];
gulp.task('pug', function () {
gulp.src('app/_pug/*.pug')
.pipe(plumber())
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('dist/'));
});
gulp.task('scss', function () {
gulp.src('app/_scss/**/*.scss')
.pipe(plumber())
.pipe(scss().on('error', scss.logError))
.pipe(gulp.dest('dist/css'));
});
gulp.task('server',function(){
bs({
port: 9000,
server: {
baseDir: 'dist'
}
})
});
gulp.task('jsLibs', function() {
return gulp.src(pathJS)
.pipe(concat('foundation.js'))
.pipe(gulp.dest('dist/js/'))
});
gulp.task('jsBuild', () => {
var options = {
watch: true,
output: {
filename: 'main.js',
library: 'app'
},
devtool: "source-map",
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
plugins: [
/* new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
unsafe: true
}
}),
new webpack.NoEmitOnErrorsPlugin()
*/
]
};
return gulp.src('app/js/main.js')
.pipe(plumber({
errorHandler: notify.onError(err => ({
title: 'Webpack',
message: err.message
}))
}))
.pipe(webpackStream(options,webpack))
.pipe(gulp.dest('dist/js/'));
});
gulp.task('imgCopy', () => {
gulp.src('app/img/*')
.pipe(gulp.dest('dist/img/'));
gulp.src('app/pictures/*')
.pipe(gulp.dest('dist/pictures/'));
});
gulp.task('copyData', () => {
gulp.src('app/data/*')
.pipe(gulp.dest('dist/data/'));
});
gulp.task('watch', function(){
gulp.watch([
'dist/*.html',
'dist/js/*.js',
'dist/css/*.css'
]).on('change', bs.reload);
gulp.watch('app/_scss/**/*',['scss']);
gulp.watch('app/_pug/**/*',['pug']);
});
gulp.task('default',['server','watch','jsLibs','imgCopy', 'copyData', 'jsBuild']);