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