forked from opendata-stuttgart/devices.sensor.community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (71 loc) · 2.45 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
require('es6-promise').polyfill();
// Defining base pathes
var basePaths = {
packages: './node_modules/',
target: './static/',
assets: './assets/'
};
// requirements
var gulp = require('gulp');
var concat = require('gulp-concat');
var cssnano = require('gulp-cssnano');
var googleWebFonts = require('gulp-google-webfonts');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var rimraf = require('gulp-rimraf');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
// gulp watch
gulp.task('watch', ['js', 'sass'], function () {
// JS
gulp.watch(basePaths.assets + 'js/*.js', ['js']);
// CSS
gulp.watch(basePaths.assets + 'sass/*.scss', ['sass']);
});
// gulp sass
gulp.task('sass', ['fonts'], function () {
gulp.src([
// basePaths.packages + 'tether/dist/css/tether.css',
basePaths.packages + 'bootstrap-multiselect/dist/css/bootstrap-multiselect.css',
basePaths.packages + 'leaflet/dist/leaflet.css',
basePaths.assets + 'sass/base.scss',
])
.pipe(sass({
noCache: true,
includePaths: ['node_modules', 'assets', 'static'],
importer: require('node-sass-tilde-importer')
}))
.pipe(cssnano({discardComments: {removeAll: true}})) // comment out for devel
.pipe(concat('webapp.min.css'))
.pipe(gulp.dest(basePaths.target + 'css/'));
});
// gulp scripts
gulp.task('js', function() {
gulp.src([
basePaths.packages + 'jquery/dist/jquery.js',
// basePaths.packages + 'tether/dist/js/tether.js',
basePaths.packages + 'leaflet/dist/leaflet.js',
basePaths.packages + 'bootstrap/dist/js/bootstrap.js',
basePaths.packages + 'bootstrap-multiselect/dist/js/bootstrap-multiselect.js',
basePaths.packages + 'bootstrap-multiselect/dist/js/bootstrap-multiselect-collapsible-groups.js',
basePaths.assets + 'js/webapp.js'
])
.pipe(concat('webapp.min.js'))
.pipe(uglify()) // comment out for devel
.pipe(gulp.dest(basePaths.target + './js/'));
});
gulp.task('fonts', function() {
gulp.src(basePaths.assets + 'fonts.list')
.pipe(googleWebFonts({
fontsDir: basePaths.target + 'fonts/',
cssDir: basePaths.target + 'fonts/',
cssFilename: 'fonts.css',
relativePaths: true,
}))
.pipe(replace('url(static', 'url(/static'))
.pipe(gulp.dest('./'));
// Font Awesome Fonts
gulp.src(basePaths.packages + 'font-awesome/fonts/**/*.{ttf,woff,woff2,eof,svg}')
.pipe(gulp.dest(basePaths.target + 'fonts/font-awesome/'));
});