-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
103 lines (87 loc) · 2.59 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
var exec = require('child_process').exec;
var gulp = require('gulp');
var sass = require('gulp-sass');
var shell = require('gulp-shell');
var sourcemaps = require('gulp-sourcemaps');
var watch = require('gulp-watch');
// Webpack build
gulp.task('build-webpack-prod', shell.task([
'webpack --config ./webpack.prod.config.js'
]))
gulp.task('build-webpack-dev', shell.task([
'webpack --config ./webpack.dev.config.js'
]))
gulp.task('watch-webpack-dev', ['build-webpack-dev'], shell.task([
'webpack --config ./webpack.dev.config.js --watch'
]))
// CLJS build
gulp.task('build-cljs-prod', ['build-webpack-prod'], shell.task([
'lein cljsbuild once min'
]));
gulp.task('watch-cljs-dev', ['build-webpack-dev'], shell.task([
'lein figwheel'
]));
// Template watch
var reloadCljsTemplate = function (file) {
templateName = file.path.split("/").pop();
exec(
"grep -rnwl 'src/' -e '"+templateName+"' | xargs touch"
);
};
gulp.task('watch-kioo-templates', function() {
gulp.watch(
'resources/private/templates/**/*'
).on("change", reloadCljsTemplate);
});
// SASS build
var includeSassPaths = ["resources/private/sass"];
var mainSassFile = 'resources/private/sass/app.scss';
var publicCssFolder = 'resources/public/css';
gulp.task('build-sass-prod', function() {
return gulp.src(mainSassFile)
.pipe(sourcemaps.init())
.pipe(
sass.sync({
outputStyle: 'compressed',
sourceComments: false,
includePaths: includeSassPaths
}))
.pipe(sourcemaps.write('.', {sourceMappingURLPrefix: '/css'}))
.pipe(gulp.dest(publicCssFolder));
});
gulp.task('build-sass-dev', function() {
return gulp.src(mainSassFile)
.pipe(
sass.sync({
sourceComments: true,
includePaths: includeSassPaths
}).on('error', sass.logError))
.pipe(gulp.dest(publicCssFolder));
});
gulp.task('watch-dev-sass', ['build-sass-dev'], function() {
gulp.watch('resources/private/**/*.{scss,css,sass}', ['build-sass-dev']);
});
// Aliases
gulp.task('clean', shell.task([
'lein clean',
'rm -rf resources/public/css/app.css',
'rm -rf resources/webpack'
]))
gulp.task('dev', ['watch-dev-sass',
'watch-cljs-dev',
'watch-kioo-templates',
'watch-webpack-dev']);
gulp.task('prod', ['build-sass-prod',
'build-webpack-prod',
'build-cljs-prod']);
gulp.task('deploy', shell.task([
"git checkout master",
"git pull",
"rm -rf docs",
"gulp clean",
"gulp prod",
"cp -r resources/public ./docs",
"git add docs/*",
"git commit -m 'Deploy'",
"git push"
]));