-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (54 loc) · 1.83 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
66
var gulp = require('gulp');
var assetsDev = 'assets/';
var assetsProd = 'src/';
var appDev = 'dev/';
var appProd = 'app/';
/* CSS */
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
var cssClean = require('gulp-clean-css');
/* JS & TS */
var typescript = require('gulp-typescript');
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('build-css', function () {
return gulp.src(assetsDev + 'scss/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(autoprefixer({
browsers: ['last 3 versions'],
cascade: false
}))
.pipe(cssClean({compatibility: 'ie8'}))
.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('bundle-ts', ['build-ts'], function() {
var path = require("path");
var Builder = require('systemjs-builder');
// optional constructor options
// sets the baseURL and loads the configuration file
var builder = new Builder('', 'systemjs.config.js');
builder
.buildStatic('app/boot.js', 'app/bundle.js', { minify: true, sourceMaps: true})
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
});
gulp.task('watch', function () {
gulp.watch(appDev + '**/*.ts', ['build-ts']);
gulp.watch(assetsDev + 'scss/**/*.scss', ['build-css']);
});
gulp.task('default', ['watch', 'build-ts', 'bundle-ts', 'build-css']);