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 | 43ffb67 | 2016-12-02 14:49:58 -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 | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 21 | function appConfig() { |
| 22 | const env = process.env.NODE_ENV || 'production'; |
| 23 | return gulp.src([ |
| 24 | path.join(conf.paths.appConfig, `app.config.${env}.ts`) |
| 25 | ]) |
| 26 | .pipe(rename('app.config.ts')) |
| 27 | .pipe(gulp.dest(cfgFolder)); |
| 28 | } |
| 29 | |
| 30 | function styleConfig() { |
| 31 | const env = process.env.BRAND || 'cord'; |
| 32 | return gulp.src([ |
| 33 | path.join(conf.paths.appConfig, `style.config.${env}.ts`) |
| 34 | ]) |
| 35 | .pipe(rename('style.config.ts')) |
| 36 | .pipe(gulp.dest(cfgFolder)); |
| 37 | } |
| 38 | |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 39 | function other() { |
| 40 | const fileFilter = filter(file => file.stat.isFile()); |
| 41 | |
| 42 | return gulp.src([ |
| 43 | path.join(conf.paths.src, '/**/*'), |
| 44 | path.join(`!${conf.paths.src}`, '/**/*.{scss,ts,html}') |
| 45 | ]) |
| 46 | .pipe(fileFilter) |
| 47 | .pipe(gulp.dest(conf.paths.dist)); |
| 48 | } |