Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 1 | const path = require('path'); |
| 2 | |
| 3 | const gulp = require('gulp'); |
| 4 | const del = require('del'); |
| 5 | const filter = require('gulp-filter'); |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 6 | const rename = require('gulp-rename'); |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 7 | const replace = require('gulp-replace'); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 8 | |
| 9 | const conf = require('../conf/gulp.conf'); |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 10 | const cfgFolder = path.join(conf.paths.src, 'app/config'); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 11 | |
| 12 | gulp.task('clean', clean); |
| 13 | gulp.task('other', other); |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 14 | gulp.task('brand', styleConfig); |
| 15 | gulp.task('appConfig', appConfig); |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 16 | gulp.task('copyCfgInterfaces', copyCfgInterfaces); |
| 17 | gulp.task('config', gulp.series('copyCfgInterfaces', 'brand', 'appConfig')); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 18 | |
| 19 | function clean() { |
| 20 | return del([conf.paths.dist, conf.paths.tmp]); |
| 21 | } |
| 22 | |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 23 | function 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 Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 34 | function 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 Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 39 | .pipe(rename('app.config.ts')) |
| 40 | .pipe(gulp.dest(cfgFolder)); |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | function styleConfig() { |
| 44 | const env = process.env.BRAND || 'cord'; |
| 45 | return gulp.src([ |
| 46 | path.join(conf.paths.appConfig, `style.config.${env}.ts`) |
| 47 | ]) |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 48 | .pipe(rename('style.config.ts')) |
| 49 | .pipe(gulp.dest(cfgFolder)); |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 50 | } |
| 51 | |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 52 | function 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 Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 60 | function 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 | } |