forked from AhsanAyaz/ng-conf-ng2-puzzle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (52 loc) · 1.68 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var gulp = require('gulp');
var assetsDev = 'assets/';
var assetsProd = 'src/';
var appDev = 'dev/';
var appProd = 'app/';
/* Mixed */
var ext_replace = require('gulp-ext-replace');
/* CSS */
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('autoprefixer');
var precss = require('precss');
var cssnano = require('cssnano');
/* JS & TS */
var jsuglify = require('gulp-uglify');
var typescript = require('gulp-typescript');
/* Images */
var imagemin = require('gulp-imagemin');
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('build-css', function () {
return gulp.src(assetsDev + 'scss/*.scss')
.pipe(sourcemaps.init())
.pipe(postcss([precss, autoprefixer, cssnano]))
.pipe(sourcemaps.write())
.pipe(ext_replace('.css'))
.pipe(gulp.dest(assetsProd + 'css/'));
});
gulp.task('build-ts', function () {
return gulp.src(appDev + '**/*.ts')
.pipe(sourcemaps.init())
.pipe(typescript(tsProject))
.pipe(sourcemaps.write())
//.pipe(jsuglify())
.pipe(gulp.dest(appProd));
});
gulp.task('build-img', function () {
return gulp.src(assetsDev + 'img/**/*')
.pipe(imagemin({
progressive: true
}))
.pipe(gulp.dest(assetsProd + 'img/'));
});
gulp.task('build-html', function () {
return gulp.src(appDev + '**/*.html')
.pipe(gulp.dest(appProd));
});
gulp.task('watch', function () {
gulp.watch(appDev + '**/*.ts', ['build-ts']);
gulp.watch(assetsDev + 'scss/**/*.scss', ['build-css']);
gulp.watch(assetsDev + 'img/*', ['build-img']);
});
gulp.task('default', ['watch', 'build-ts', 'build-css']);