@@ -5,38 +5,24 @@ var gulp = require('gulp');
55var conf = require ( './conf' ) ;
66
77var browserSync = require ( 'browser-sync' ) ;
8- < % if ( props . jsPreprocessor . srcExtension === 'es6' ) { - % >
8+ < % if ( props . jsPreprocessor . srcExtension === 'es6' || props . jsPreprocessor . key === 'typescript' ) { - % >
99var webpack = require ( 'webpack-stream' ) ;
1010< % } - % >
1111
1212var $ = require ( 'gulp-load-plugins' ) ( ) ;
1313
14- < % if ( props . jsPreprocessor . srcExtension !== 'es6' ) { - % >
15- < % if ( props . jsPreprocessor . key === 'typescript' ) { - % >
16- var tsProject = $ . typescript . createProject ( {
17- target : 'es5' ,
18- sortOutput : true
19- } ) ;
20-
21- gulp . task ( 'scripts' , [ 'tsd:install' ] , function ( ) {
22- < % } else { - % >
14+ < % if ( props . jsPreprocessor . srcExtension !== 'es6' && props . jsPreprocessor . key !== 'typescript' ) { - % >
2315gulp . task ( 'scripts' , function ( ) {
24- < % } - % >
2516 return gulp . src ( path . join ( conf . paths . src , '/app/**/*.<%- props.jsPreprocessor.extension %>' ) )
2617< % if ( props . jsPreprocessor . extension === 'js' ) { - % >
27- . pipe ( $ . jshint ( ) )
28- . pipe ( $ . jshint . reporter ( 'jshint-stylish' ) )
18+ . pipe ( $ . eslint ( ) )
19+ . pipe ( $ . eslint . format ( ) )
2920< % } if ( props . jsPreprocessor . key !== 'none' ) { - % >
3021 . pipe ( $ . sourcemaps . init ( ) )
3122< % } if ( props . jsPreprocessor . key === 'coffee' ) { - % >
3223 . pipe ( $ . coffeelint ( ) )
3324 . pipe ( $ . coffeelint . reporter ( ) )
3425 . pipe ( $ . coffee ( ) ) . on ( 'error' , conf . errorHandler ( 'CoffeeScript' ) )
35- < % } if ( props . jsPreprocessor . key === 'typescript' ) { - % >
36- . pipe ( $ . tslint ( ) )
37- . pipe ( $ . tslint . report ( 'prose' , { emitError : false } ) )
38- . pipe ( $ . typescript ( tsProject ) ) . on ( 'error' , conf . errorHandler ( 'TypeScript' ) )
39- . pipe ( $ . concat ( 'index.module.js' ) )
4026< % } if ( props . jsPreprocessor . key !== 'none' ) { - % >
4127 . pipe ( $ . sourcemaps . write ( ) )
4228 . pipe ( gulp . dest ( path . join ( conf . paths . tmp , '/serve/app' ) ) )
@@ -47,13 +33,22 @@ gulp.task('scripts', function () {
4733< % } else { - % >
4834function webpackWrapper ( watch , callback ) {
4935 var webpackOptions = {
36+ < % if ( props . jsPreprocessor . key === 'typescript' ) { - % >
37+ resolve : { extensions : [ '' , '.ts' ] } ,
38+ < % } - % >
5039 watch : watch ,
5140 module : {
52- preLoaders : [ { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'jshint-loader' } ] ,
41+ < % if ( props . jsPreprocessor . extension = = = 'js' ) { - % >
42+ preLoaders : [ { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'eslint-loader' } ] ,
43+ < % } if ( props . jsPreprocessor . key === 'typescript' ) { - % >
44+ preLoaders : [ { test : / \. t s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'tslint-loader' } ] ,
45+ < % } - % >
5346< % if ( props . jsPreprocessor . key = = = 'babel' ) { - % >
5447 loaders : [ { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'babel-loader' } ]
5548< % } if ( props . jsPreprocessor . key === 'traceur' ) { - % >
5649 loaders : [ { test : / \. j s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'traceur-loader' } ]
50+ < % } if ( props . jsPreprocessor . key === 'typescript' ) { - % >
51+ loaders : [ { test : / \. t s $ / , exclude : / n o d e _ m o d u l e s / , loader : 'awesome-typescript-loader' } ]
5752< % } - % >
5853 } ,
5954 output : { filename : 'index.module.js' }
@@ -80,12 +75,16 @@ function webpackWrapper(watch, callback) {
8075 }
8176 } ;
8277
83- return gulp . src ( path . join ( conf . paths . src , '/app/index.module.js ' ) )
78+ return gulp . src ( path . join ( conf . paths . src , '/app/index.module.<%- props.jsPreprocessor.extension %> ' ) )
8479 . pipe ( webpack ( webpackOptions , null , webpackChangeHandler ) )
8580 . pipe ( gulp . dest ( path . join ( conf . paths . tmp , '/serve/app' ) ) ) ;
8681}
8782
83+ < % if ( props . jsPreprocessor . key === 'typescript' ) { - % >
84+ gulp . task ( 'scripts' , [ 'tsd:install' ] , function ( ) {
85+ < % } else { % >
8886gulp . task ( 'scripts' , function ( ) {
87+ < % } % >
8988 return webpackWrapper ( false ) ;
9089} ) ;
9190
0 commit comments