forked from geex-arts/django-jet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
132 lines (122 loc) · 4.35 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require('es6-promise').polyfill();
var gulp = require('gulp'),
browserify = require('browserify'),
concatCss = require('gulp-concat-css'),
cleanCSS = require('gulp-clean-css'),
sass = require('gulp-sass'),
uglify = require('gulp-uglify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
sourcemaps = require('gulp-sourcemaps'),
merge = require('merge-stream'),
postcss = require('gulp-postcss'),
pxtorem = require('postcss-pxtorem'),
autoprefixer = require('autoprefixer'),
shell = require('gulp-shell'),
replace = require('gulp-replace');
var cssProcessors = [
autoprefixer(),
pxtorem({
rootValue: 14,
replace: false,
propWhiteList: []
})
];
gulp.task('scripts', function() {
return browserify('./jet/static/jet/js/src/main.js')
.bundle()
.on('error', function(error) {
console.error(error);
})
.pipe(source('bundle.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./jet/static/jet/js/build/'));
});
gulp.task('styles', function() {
return gulp.src('./jet/static/jet/css/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compressed'
}))
.on('error', function(error) {
console.error(error);
})
.pipe(postcss(cssProcessors))
.on('error', function(error) {
console.error(error);
})
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./jet/static/jet/css'));
});
gulp.task('vendor-styles', function() {
return merge(
gulp.src('./node_modules/jquery-ui/themes/base/images/*')
.pipe(gulp.dest('./jet/static/jet/css/jquery-ui/images/')),
merge(
gulp.src([
'./node_modules/select2/dist/css/select2.css',
'./node_modules/timepicker/jquery.ui.timepicker.css'
]),
gulp.src([
'./node_modules/jquery-ui/themes/base/all.css'
])
.pipe(cleanCSS()) // needed to remove jQuery UI comments breaking concatCss
.on('error', function(error) {
console.error(error);
})
.pipe(concatCss('jquery-ui.css', {
rebaseUrls: false
}))
.on('error', function(error) {
console.error(error);
})
.pipe(replace('images/', 'jquery-ui/images/'))
.on('error', function(error) {
console.error(error);
}),
gulp.src([
'./node_modules/perfect-scrollbar/src/css/main.scss'
])
.pipe(sass({
outputStyle: 'compressed'
}))
.on('error', function(error) {
console.error(error);
})
)
.pipe(postcss(cssProcessors))
.on('error', function(error) {
console.error(error);
})
.pipe(concatCss('vendor.css', {
rebaseUrls: false
}))
.on('error', function(error) {
console.error(error);
})
.pipe(cleanCSS())
.on('error', function(error) {
console.error(error);
})
.pipe(gulp.dest('./jet/static/jet/css'))
)
});
gulp.task('vendor-translations', function() {
return merge(
gulp.src(['./node_modules/jquery-ui/ui/i18n/*.js'])
.pipe(gulp.dest('./jet/static/jet/js/i18n/jquery-ui/')),
gulp.src(['./node_modules/timepicker/i18n/*.js'])
.pipe(gulp.dest('./jet/static/jet/js/i18n/jquery-ui-timepicker/')),
gulp.src(['./node_modules/select2/dist/js/i18n/*.js'])
.pipe(gulp.dest('./jet/static/jet/js/i18n/select2/'))
)
});
gulp.task('locales', shell.task('python manage.py compilemessages', { quiet: true }));
gulp.task('build', ['scripts', 'styles', 'vendor-styles', 'vendor-translations', 'locales']);
gulp.task('watch', function() {
gulp.watch('./jet/static/jet/js/src/**/*.js', ['scripts']);
gulp.watch('./jet/static/jet/css/**/*.scss', ['styles']);
gulp.watch(['./jet/locale/**/*.po', './jet/dashboard/locale/**/*.po'], ['locales']);
});
gulp.task('default', ['build', 'watch']);