blob: 0e6a3fd393ae2d4922175e10302f1f84fa338d9d [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 Scandoloe0d71ea2016-12-19 11:56:12 -08007const replace = require('gulp-replace');
Matteo Scandolod819c922016-12-02 14:06:14 -08008
9const conf = require('../conf/gulp.conf');
Matteo Scandolo43ffb672016-12-02 14:49:58 -080010const cfgFolder = path.join(conf.paths.src, 'app/config');
Matteo Scandolod819c922016-12-02 14:06:14 -080011
12gulp.task('clean', clean);
13gulp.task('other', other);
Matteo Scandolo43ffb672016-12-02 14:49:58 -080014gulp.task('brand', styleConfig);
15gulp.task('appConfig', appConfig);
Matteo Scandoloe0d71ea2016-12-19 11:56:12 -080016gulp.task('copyCfgInterfaces', copyCfgInterfaces);
17gulp.task('config', gulp.series('copyCfgInterfaces', 'brand', 'appConfig'));
Matteo Scandolod819c922016-12-02 14:06:14 -080018
19function clean() {
20 return del([conf.paths.dist, conf.paths.tmp]);
21}
22
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080023function other() {
24 const fileFilter = filter(file => file.stat.isFile());
25
26 return gulp.src([
27 path.join(conf.paths.src, '/**/*'),
28 path.join(`!${conf.paths.src}`, '/**/*.{scss,ts,html}')
29 ])
30 .pipe(fileFilter)
31 .pipe(gulp.dest(conf.paths.dist));
32}
33
Matteo Scandolo43ffb672016-12-02 14:49:58 -080034function appConfig() {
35 const env = process.env.NODE_ENV || 'production';
36 return gulp.src([
37 path.join(conf.paths.appConfig, `app.config.${env}.ts`)
38 ])
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080039 .pipe(rename('app.config.ts'))
40 .pipe(gulp.dest(cfgFolder));
Matteo Scandolo43ffb672016-12-02 14:49:58 -080041}
42
43function styleConfig() {
44 const env = process.env.BRAND || 'cord';
45 return gulp.src([
46 path.join(conf.paths.appConfig, `style.config.${env}.ts`)
47 ])
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080048 .pipe(rename('style.config.ts'))
49 .pipe(gulp.dest(cfgFolder));
Matteo Scandolo43ffb672016-12-02 14:49:58 -080050}
51
Matteo Scandoloe0d71ea2016-12-19 11:56:12 -080052function copyCfgInterfaces() {
53 return gulp.src([
54 path.join(conf.paths.appConfig, `interfaces.ts`)
55 ])
56 .pipe(replace('../../src/app/core/services/navigation', '../core/services/navigation'))
57 .pipe(gulp.dest(cfgFolder));
58}
59
Matteo Scandolod819c922016-12-02 14:06:14 -080060function other() {
61 const fileFilter = filter(file => file.stat.isFile());
62
63 return gulp.src([
64 path.join(conf.paths.src, '/**/*'),
65 path.join(`!${conf.paths.src}`, '/**/*.{scss,ts,html}')
66 ])
67 .pipe(fileFilter)
68 .pipe(gulp.dest(conf.paths.dist));
69}