-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
150 lines (121 loc) · 3.7 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Generated on 2015-04-17 using generator-jhipster 2.7.0
/* jshint camelcase: false */
'use strict';
var gulp = require('gulp');
gulp.task('clean', ['clean:elm'], function (cb) {
var del = require('del');
del('build/resources/main/public', cb);
});
gulp.task('clean:elm', function (cb) {
var del = require('del');
del('elm-stuff/build-artifacts', cb);
});
gulp.task('web', function (cb) {
var mkdirp = require('mkdirp');
mkdirp('build/resources/main/public', '0775', function () {
cb();
});
});
gulp.task('app.js', ['web'], function (cb) {
var exec = require('child_process').exec;
exec('node_modules/elm/bin/elm-make src/main/elm/App.elm --output build/resources/main/public/app.js', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('test', function (cb) {
var exec = require('child_process').exec;
exec('node_modules/elm/bin/elm-make src/main/elm/Test.elm --output build/test.html', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
exec('open build/test.html');
cb(err);
});
});
gulp.task('signals.svg', function (cb) {
var exec = require('child_process').exec;
exec('dot src/main/elm/signals.gv -Tsvg -o src/main/elm/signals.svg', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('bower', ['web'], function (cb) {
var exec = require('child_process').exec;
exec('./node_modules/bower/bin/bower install', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('scss:dir', function (cb) {
var mkdirp = require('mkdirp');
mkdirp('build/scss', '0775', function () {
cb();
});
});
gulp.task('scss:inject', ['scss:dir', 'bower'], function () {
var inject = require('gulp-inject');
var sort = require('gulp-sort');
return gulp.src('src/main/web/main.scss').pipe(
inject(gulp.src([
'src/main/elm/**/*.scss'
], {
read: false
}).pipe(
sort()
), {
starttag: '// inject:scss',
endtag: '// endinject',
relative: false,
transform: function (filepath, file, i, length) {
return '@import "../..' + filepath + '";';
}
})
).pipe(
gulp.dest('build/scss')
);
});
gulp.task('scss:compile', ['scss:inject'], function (cb) {
var sass = require('node-sass');
var fs = require('fs');
sass.render({
file: 'build/scss/main.scss',
}, function (err, result) {
if (err) {
console.log(JSON.stringify(err, null, 4));
cb();
} else {
fs.writeFile('build/scss/main.css', result.css, cb);
}
});
});
gulp.task('prefix', ['scss:compile'], function () {
var prefix = require('gulp-prefix');
return gulp.src(
'build/scss/main.css'
).pipe(
prefix()
).pipe(
gulp.dest('build/resources/main/public')
);
});
gulp.task('index.html', ['web', 'bower'], function () {
var wiredep = require('wiredep').stream;
return gulp.src(
'src/main/web/index.html'
).pipe(
wiredep({
ignorePath: '../../../build/resources/main/public/'
})
).pipe(
gulp.dest('build/resources/main/public')
);
});
gulp.task('images', ['web'], function () {
return gulp.src('src/main/elm/**/*.jpg').pipe(
gulp.dest('build/resources/main/public/images')
);
});
gulp.task('default', ['app.js', 'index.html', 'prefix', 'images']);