-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
51 lines (41 loc) · 1.43 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
const gulp = require( 'gulp' );
const sass = require( 'gulp-sass' );
const webpack = require( 'webpack' );
const ts = require( "gulp-typescript" );
const tsProject = ts.createProject( 'tsconfig-server.json', { noImplicitAny: true } );
gulp.task( 'static', function( callback ) {
return gulp.src( './src/static/**/*' )
.pipe( gulp.dest( './dist/client/' ) );
} );
gulp.task( 'build-client', function( callback ) {
webpack( require( './webpack.config.js' ), function( err, stats ) {
if ( err )
throw err;
callback();
} );
} );
gulp.task( 'build-server', function( callback ) {
const tsResult = tsProject.src()
.pipe( tsProject() )
return tsResult.js.pipe( gulp.dest( './dist/server' ) );
} );
gulp.task( 'build-ts-files', [ 'build-client', 'build-server' ], function( callback ) {
callback();
} );
gulp.task( 'sass', function() {
return gulp.src( './src/main.scss' )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( gulp.dest( './dist/client/css' ) );
} );
gulp.task( 'static:watch', function() {
gulp.watch( './src/static/**/*.*', [ 'static' ] );
} );
gulp.task( 'sass:watch', function() {
gulp.watch( './src/**/*.scss', [ 'sass' ] );
} );
gulp.task( 'tsx:watch', function() {
gulp.watch( './src/**/*.tsx', [ 'build-ts-files' ] );
} );
gulp.task( 'build', [ 'build-ts-files', 'sass', 'static' ] );
gulp.task( 'watch', [ 'sass:watch', 'tsx:watch', 'static:watch' ] );
gulp.task( 'default', [ 'build' ] );