blob: e9fe0f0f61deea5b7c186649b0823543c694d52f [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001const path = require('path');
2
3const gulp = require('gulp');
4const del = require('del');
5const filter = require('gulp-filter');
Matteo Scandolof6acdbe2016-12-13 10:29:37 -08006const rename = require('gulp-rename');
Matteo Scandolod819c922016-12-02 14:06:14 -08007
8const conf = require('../conf/gulp.conf');
Matteo Scandolo43ffb672016-12-02 14:49:58 -08009const cfgFolder = path.join(conf.paths.src, 'app/config');
Matteo Scandolod819c922016-12-02 14:06:14 -080010
11gulp.task('clean', clean);
12gulp.task('other', other);
Matteo Scandolo43ffb672016-12-02 14:49:58 -080013gulp.task('brand', styleConfig);
14gulp.task('appConfig', appConfig);
15gulp.task('config', gulp.series('brand', 'appConfig'));
Matteo Scandolod819c922016-12-02 14:06:14 -080016
17function clean() {
18 return del([conf.paths.dist, conf.paths.tmp]);
19}
20
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080021function other() {
22 const fileFilter = filter(file => file.stat.isFile());
23
24 return gulp.src([
25 path.join(conf.paths.src, '/**/*'),
26 path.join(`!${conf.paths.src}`, '/**/*.{scss,ts,html}')
27 ])
28 .pipe(fileFilter)
29 .pipe(gulp.dest(conf.paths.dist));
30}
31
Matteo Scandolo43ffb672016-12-02 14:49:58 -080032function appConfig() {
33 const env = process.env.NODE_ENV || 'production';
34 return gulp.src([
35 path.join(conf.paths.appConfig, `app.config.${env}.ts`)
36 ])
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080037 .pipe(rename('app.config.ts'))
38 .pipe(gulp.dest(cfgFolder));
Matteo Scandolo43ffb672016-12-02 14:49:58 -080039}
40
41function styleConfig() {
42 const env = process.env.BRAND || 'cord';
43 return gulp.src([
44 path.join(conf.paths.appConfig, `style.config.${env}.ts`)
45 ])
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080046 .pipe(rename('style.config.ts'))
47 .pipe(gulp.dest(cfgFolder));
Matteo Scandolo43ffb672016-12-02 14:49:58 -080048}
49
Matteo Scandolod819c922016-12-02 14:06:14 -080050function other() {
51 const fileFilter = filter(file => file.stat.isFile());
52
53 return gulp.src([
54 path.join(conf.paths.src, '/**/*'),
55 path.join(`!${conf.paths.src}`, '/**/*.{scss,ts,html}')
56 ])
57 .pipe(fileFilter)
58 .pipe(gulp.dest(conf.paths.dist));
59}