-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
118 lines (102 loc) · 3.31 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
'use strict';
var path = require('path');
var gulp = require('gulp');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var minifyCss = require('gulp-clean-css');
var prefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var less = require('gulp-less');
var watch = require('gulp-watch');
var frontSrcDir = path.join(__dirname, '/app/front');
var frontScriptsDir = path.join(frontSrcDir, '/scripts');
var frontStylesDir = path.join(frontSrcDir, '/styles');
var frontAssetsDir = path.join(frontSrcDir, '/assets');
var publicDir = path.join(__dirname, '/app/public');
var publicStylesDir = path.join(publicDir, '/styles');
var publicFontsDir = path.join(publicDir, '/fonts');
var publicAssetsDir = path.join(publicDir, '/assets');
var viewsDir = path.join(__dirname, '/app/views');
var servicesDir = path.join(__dirname, '/app/services');
var nodeModulesDir = path.join(__dirname, '/node_modules');
gulp.task('default', [
'styles',
'assets'
]);
gulp.task('watch', ['default'], function() {
var files = [
path.join(frontScriptsDir, '/**/*.js'),
path.join(servicesDir, '/**/*.js'),
path.join(frontStylesDir, '/**/*.less'),
path.join(viewsDir, '/**/*.html')
];
watch(files, {usePolling: true}, function() {
gulp.start('default');
});
});
// Styles
gulp.task('styles', [
'styles.vendor',
'styles.application'
]);
gulp.task('styles.application', function() {
var files = [
path.join(frontStylesDir, '/styles.less')
];
return gulp.src(files)
.pipe(sourcemaps.init())
.pipe(less())
.pipe(prefixer({browsers: ['last 4 versions']}))
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(concat('app.css'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(publicStylesDir));
});
gulp.task('styles.vendor', function() {
var files = [
path.join(nodeModulesDir, '/font-awesome/css/font-awesome.min.css'),
path.join(nodeModulesDir, '/os-bootstrap/dist/css/os-bootstrap.min.css'),
path.join(nodeModulesDir, '/angular/angular-csp.css'),
path.join(nodeModulesDir, '/typeahead.js-bootstrap-css/typeaheadjs.css'),
path.join(nodeModulesDir, '/goodtables-ui/dist/goodtables-ui.min.css')
];
return gulp.src(files)
.pipe(concat('vendor.css'))
.pipe(gulp.dest(publicStylesDir));
});
// Assets
gulp.task('assets', [
'assets.fonts',
'assets.images',
'assets.favicon'
]);
gulp.task('assets.fonts', function() {
var files = [
path.join(nodeModulesDir, '/font-awesome/fonts/*'),
path.join(nodeModulesDir, '/os-bootstrap/dist/fonts/*')
];
return gulp.src(files)
.pipe(gulp.dest(publicFontsDir));
});
gulp.task('assets.images', function() {
var files = [
path.join(frontAssetsDir, '/**/*'),
path.join(nodeModulesDir,
'/os-bootstrap/dist/assets/os-branding/vector/light/os.svg'),
path.join(nodeModulesDir,
'/os-bootstrap/dist/assets/os-branding/vector/light/packager.svg'),
path.join(nodeModulesDir,
'/os-bootstrap/dist/assets/os-branding/vector/light/ospackager.svg')
];
return gulp.src(files)
.pipe(gulp.dest(publicAssetsDir));
});
gulp.task('assets.favicon', function() {
var files = [
path.join(nodeModulesDir,
'/os-bootstrap/dist/assets/os-branding/packager-favicon.ico')
];
return gulp.src(files)
.pipe(rename('favicon.ico'))
.pipe(gulp.dest(publicDir));
});