forked from komitywa/wysadzulice.pl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
122 lines (104 loc) · 3.49 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import autoprefixer from 'gulp-autoprefixer';
import babelify from 'babelify';
import browserify from 'browserify';
import concat from 'gulp-concat';
import del from 'del';
import domain from 'domain';
import flatten from 'gulp-flatten';
import filter from 'gulp-filter';
import gulp from 'gulp';
import gutil from 'gulp-util';
import hbsfy from 'hbsfy';
import plumber from 'gulp-plumber';
import sass from 'gulp-sass';
import tap from 'gulp-tap';
/* Default task */
gulp.task('default', function() {
gulp.start('build');
});
/* Removing whole ./wysadzulice/static/ directory */
gulp.task('clean', del.bind(null, './wysadzulice/static'));
/* Building JS */
gulp.task('js', function() {
return gulp.src('./wysadzulice/assets/main.js')
.pipe(plumber())
.pipe(tap(function(file) {
const dom = domain.create();
dom.on('error', function(err) {
gutil.log(
gutil.colors.red('Browserify compile error:'),
err.message, '\n\t',
gutil.colors.cyan('in file'), file.path
);
gutil.beep();
});
dom.run(function() {
file.contents = browserify({
entries: [file.path],
debug: false,
standalone: 'WysadzUlice',
paths: ['./node_modules/', './wysadzulice/assets/'],
transform: [
[hbsfy, {
global: true,
ignore: /\/node_modules\/(?!plantingjs\/)/,
}],
[babelify, {
global: true,
ignore: /\/node_modules\/(?!plantingjs\/)/,
}],
],
}).bundle();
});
}))
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/js/'));
});
/* End of building JS */
/* Building CSS */
gulp.task('css:main', function() {
return gulp.src('./wysadzulice/assets/styles/**/*.scss')
.pipe(sass())
.pipe(autoprefixer({browsers: ['last 1 version']}))
.pipe(concat('main.css'))
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/styles/'));
});
gulp.task('css:vendor', function() {
return gulp.src([
'./node_modules/jquery-ui/themes/base/jquery-ui.css',
'./node_modules/jquery-ui/themes/base/jquery.ui.dialog.css',
'./node_modules/plantingjs/src/styles/*.scss',
])
.pipe(sass())
.pipe(concat('vendor.css'))
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/styles/'));
});
gulp.task('css', ['css:vendor', 'css:main']);
/* End of building CSS */
/* Building fonts */
gulp.task('fonts', function() {
return gulp.src('./node_modules/plantingjs/src/fonts/**/*')
.pipe(filter('**/*.{eot,svg,ttf,woff}'))
.pipe(flatten())
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/fonts'));
});
/* End of building fonts */
/* Building assets */
gulp.task('assets:main', function() {
return gulp.src('./wysadzulice/assets/assets/**/*')
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/assets/main'));
});
gulp.task('assets:vendor', function() {
return gulp.src('./wysadzulice/assets/assets/**/*')
.pipe(gulp.dest('./wysadzulice/static/wysadzulice/assets/vendor'));
});
gulp.task('assets', ['assets:main', 'assets:vendor']);
/* End of building assets */
/* Building all frontend assets */
gulp.task('build', ['assets', 'css', 'fonts', 'js']);
/* End of building all frontend assets */
gulp.task('watch', function(){
gulp.watch('./wysadzulice/assets/assets/catalog/*.png', ['assets']);
gulp.watch('./wysadzulice/assets/js/**/*.js', ['js']);
gulp.watch('./wysadzulice/assets/main.js', ['js']);
gulp.watch('./wysadzulice/assets/styles/**/*.scss', ['css:main']);
});