@ -15,6 +15,7 @@ var cleancss = require('gulp-clean-css');
var filter = require ( 'gulp-filter' ) ;
var filter = require ( 'gulp-filter' ) ;
var systemJSBuilder = require ( 'systemjs-builder' ) ;
var systemJSBuilder = require ( 'systemjs-builder' ) ;
var run = require ( 'gulp-run' ) ;
var run = require ( 'gulp-run' ) ;
var fs = require ( 'fs' ) ;
var wwwroot = './wwwroot' ;
var wwwroot = './wwwroot' ;
@ -32,16 +33,13 @@ var paths = {
'@angular/http' ,
'@angular/http' ,
'@angular/router' ,
'@angular/router' ,
'@angular/forms' ,
'@angular/forms' ,
'@angular/platform-browser/animations' ,
'ngx-infinite-scroll'
] ,
] ,
dest : './lib'
dest : './lib'
} ,
} ,
lib : { // These are simple single-file dependencies with optional rename, for more files or folders use modules
lib : { // These are simple single-file dependencies with optional rename, for more files or folders use modules
src : [
src : [
{
file : './node_modules/@angular/platform-browser/bundles/platform-browser-animations.umd.js' ,
rename : '@angular/platform-browser/animations'
} ,
{
{
file : './node_modules/systemjs/dist/system.src.js' ,
file : './node_modules/systemjs/dist/system.src.js' ,
rename : 'system'
rename : 'system'
@ -89,7 +87,7 @@ var paths = {
src : [
src : [
'./node_modules/primeng/resources/themes/omega/fonts/*'
'./node_modules/primeng/resources/themes/omega/fonts/*'
] ,
] ,
dest : './ fonts/'
dest : './ css/ fonts/'
}
}
] ,
] ,
libimages : [ // Library images
libimages : [ // Library images
@ -120,12 +118,7 @@ var paths = {
name : 'primeng' ,
name : 'primeng' ,
src : './node_modules/primeng/**/*.js' ,
src : './node_modules/primeng/**/*.js' ,
dest : './lib/primeng/'
dest : './lib/primeng/'
} ,
}
{
name : "angular2-infinite-scroll" ,
src : [ './node_modules/angular2-infinite-scroll/**/*.js' , '!./node_modules/angular2-infinite-scroll/bundles/**/*.js' ] ,
dest : "./lib/angular2-infinite-scroll/"
} ,
] ,
] ,
sass : { // Simple sass->css compilation
sass : { // Simple sass->css compilation
src : [ './Styles/**/*.scss' , '!./Styles/primeng/**' ] ,
src : [ './Styles/**/*.scss' , '!./Styles/primeng/**' ] ,
@ -252,7 +245,7 @@ gulp.task('sass', function () {
} ) ;
} ) ;
gulp . task ( 'bundle' , function ( ) {
gulp . task ( 'bundle' , [ 'typescript_firstrun' ] , function ( ) {
var builder = new systemJSBuilder ( paths . bundle . root ) ;
var builder = new systemJSBuilder ( paths . bundle . root ) ;
builder . config ( paths . bundle . config ) ;
builder . config ( paths . bundle . config ) ;
@ -264,15 +257,32 @@ gulp.task('bundle', function () {
gulp . task ( 'clean' , function ( ) {
gulp . task ( 'clean' , function ( ) {
return del ( [
return del ( [
paths . sass . dest ,
paths . sass . dest + paths . sass . filter ,
paths . lib . dest ,
paths . lib . dest ,
paths . bundle . dest ,
paths . bundle . dest ,
... paths . modules . map ( m => m . dest )
... paths . modules . map ( m => m . dest ) ,
... paths . libcss . map ( m => m . dest + ( m . filter ? m . filter : '' ) ) ,
... paths . libfonts . map ( m => m . dest )
] . map ( x => path . join ( paths . wwwroot , x ) ) , { force : true } ) ;
] . map ( x => path . join ( paths . wwwroot , x ) ) , { force : true } ) ;
} )
} )
gulp . task ( 'typescript' , function ( ) {
// Runs the TypeScript compiler
function runTSC ( ) {
return run ( 'tsc' ) . exec ( ) ;
return run ( 'tsc' ) . exec ( ) ;
}
// Allows app to bundle libs on first run by compiling the app first, only compiles if entry point doesn't exist
gulp . task ( 'typescript_firstrun' , function ( ) {
var bundle = path . join ( paths . wwwroot , paths . bundle . bundle ) ;
var exists = fs . existsSync ( bundle ) ;
if ( ! exists ) {
console . log ( ` ' ${ bundle } ' doesn't exist - compiling TypeScript ` ) ;
return runTSC ( ) ;
}
} )
gulp . task ( 'typescript' , function ( ) {
return runTSC ( ) ;
} ) ;
} ) ;
uglify ( ) . on ( 'error' ,
uglify ( ) . on ( 'error' ,
@ -285,7 +295,7 @@ gulp.task('fullvar', () => { global.full = true });
gulp . task ( 'copy' , [ 'lib' , 'libcss' , 'libfonts' , 'libimages' , 'npm' , 'modules' ] ) ;
gulp . task ( 'copy' , [ 'lib' , 'libcss' , 'libfonts' , 'libimages' , 'npm' , 'modules' ] ) ;
gulp . task ( 'compile' , callback => runSequence ( 'copy' , 'sass' , callback ) ) ;
gulp . task ( 'compile' , callback => runSequence ( 'copy' , 'sass' , callback ) ) ;
gulp . task ( 'build' , callback => runSequence ( 'compile' , 'bundle' , callback ) ) ;
gulp . task ( 'build' , callback => runSequence ( 'compile' , 'bundle' , callback ) ) ;
gulp . task ( 'full' , callback => runSequence ( /*'clean',*/ 'compile' , callback ) ) ;
gulp . task ( 'full' , callback => runSequence ( 'clean' , 'compile' , callback ) ) ;
// Use this in a build server environment to compile and bundle everything
// Use this in a build server environment to compile and bundle everything
gulp . task ( 'publish' , callback => runSequence ( 'fullvar' , 'full' , 'typescript' , 'bundle' , callback ) ) ;
gulp . task ( 'publish' , callback => runSequence ( 'fullvar' , 'full' , 'typescript' , 'bundle' , callback ) ) ;