/
styles.js
57 lines (46 loc) · 1.61 KB
/
styles.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
/*******************************************************************************
* Copyright (c) 2015 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
'use strict';
var gulp = require('gulp');
var paths = gulp.paths;
var $ = require('gulp-load-plugins')();
gulp.task('styles', function () {
var injectFiles = gulp.src([
paths.src + '/{app,components}/**/*.styl',
'!' + paths.src + '/app/index.styl',
'!' + paths.src + '/app/vendor.styl'
], { read: false });
var injectOptions = {
transform: function(filePath) {
filePath = filePath.replace(paths.src + '/app/', '');
filePath = filePath.replace(paths.src + '/components/', '../components/');
return '@import \'' + filePath + '\';';
},
starttag: '// injector',
endtag: '// endinjector',
addRootSlash: false
};
var indexFilter = $.filter('index.styl');
return gulp.src([
paths.src + '/app/index.styl',
paths.src + '/app/vendor.styl'
])
.pipe(indexFilter)
.pipe($.inject(injectFiles, injectOptions))
.pipe(indexFilter.restore())
.pipe($.stylus())
.pipe($.autoprefixer())
.on('error', function handleError(err) {
console.error(err.toString());
this.emit('end');
})
.pipe(gulp.dest(paths.tmp + '/serve/app/'));
});