-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
106 lines (95 loc) · 2.67 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
cssnano = require('gulp-cssnano'),
sourcemaps = require('gulp-sourcemaps'),
nodemon = require('gulp-nodemon'),
webpackStream = require('webpack-stream'),
webpack = require('webpack'),
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
tslint = require('gulp-tslint');
let browserSync = gutil.env.production ?
undefined : require('browser-sync').create();
const paths = {
server: [
'src/server/**/*.ts',
'src/shared/**/*.ts',
],
ts: [
'src/client/**/*.ts',
'src/shared/**/*.ts',
'src/client/**/*.tsx'
]
};
gulp.task('css', function () {
gutil.log('Generating css');
let stream = gulp.src('src/assets/scss/checkin.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer('last 4 version'))
.pipe(gulp.dest('src/assets/public/css'))
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulpif(!gutil.env.production, sourcemaps.write()))
.pipe(gulp.dest('src/assets/public/css'));
if (browserSync) {
stream.pipe(browserSync.stream());
}
return stream;
});
gulp.task('tslint', function() {
return gulp.src(paths.ts)
.pipe(tslint({
formatter: 'stylish'
}))
.pipe(tslint.report({
allowWarnings: true
}));
});
gulp.task('nodemon', ['css'], function(cb) {
return nodemon({
exec: './node_modules/.bin/ts-node -P ./src/server/tsconfig.json '+
'-r tsconfig-paths/register ./src/server/main.ts',
ext: 'ts',
watch: paths.server,
env: {
'NODE_ENV': 'development',
'TS_NODE_FILES': 'true',
'PORT': 3000
}
})
.once('start', function() {
cb();
})
.on('restart', function() {
gulp.start('css');
});
});
gulp.task('webpack', ['tslint'], function() {
gulp.src('src/client/main.tsx')
.pipe(webpackStream(require('./webpack.config.prod.js'), webpack))
.pipe(gulp.dest('src/assets/public/js'));
});
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
port: 8000,
proxy: {
target: 'localhost:3000'
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('test', ['webpack']);
gulp.task('default', ['css', 'browser-sync'], function () {
gulp.watch('src/assets/scss/**/*.scss', ['css']);
});
/**
* DISCLAIMER: If running this on a development machine, be sure to remove frontend
* build artifacts from `src/assets/public/js` - your last production build will override
* your future development builds if this directory is not deleted.
*/
gulp.task('prod', ['webpack', 'css']);