Last active
March 23, 2017 06:44
-
-
Save Yonkokilasi/b1301fd784ef280d57e68700abb584d1 to your computer and use it in GitHub Desktop.
This is my gulp file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
installations | |
npm install gulp-concat --save-dev | |
npm install vinyl-source-stream --save-dev | |
sudo npm install gulp -g | |
npm install gulp-uglify | |
npm install gulp-util --save-dev | |
npm install del --save-dev | |
npm install jshint --save-dev | |
npm install gulp-jshint --save-dev | |
npm install browser-sync --save-dev | |
required for bower | |
npm install | |
bower install | |
bower install moment --save | |
npm install bower-files --save-dev | |
bower install bootstrap --save | |
var gulp = require('gulp'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var utilities = require('gulp-util'); | |
var buildProduction = utilities.env.production; | |
var del = require('del'); | |
var shell = require('gulp-shell'); | |
var lib = require('bower-files')({ | |
"overrides": { | |
"bootstrap": { | |
"main": [ | |
"less/bootstrap.less", | |
"dist/css/bootstrap.css", | |
"dist/js/bootstrap.js" | |
] | |
} | |
} | |
}); | |
var browserSync = require('browser-sync').create(); | |
var sass = require('gulp-sass'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
//var jshint = require('gulp-jshint'); | |
gulp.task('myTask', function() { | |
console.log('hello gulp'); | |
}); | |
//This concats the code so that it's short' | |
gulp.task('concatInterface', function() { | |
return gulp.src(['./resources/js/*interface.js']) // array of js files to be concated | |
.pipe(concat('allConcat.js')) //makes a folder called allConcat.js | |
.pipe(gulp.dest('./tmp')); // destination is the tmp folder | |
}); | |
//When browserify is run it will also run concat at the same time but it has to be predefined | |
gulp.task('jsBrowserify', ['concatInterface'], function() { | |
return browserify({ | |
entries: ['./tmp/allConcat.js'] | |
}) | |
.bundle() | |
.pipe(source('app.js')) | |
.pipe(gulp.dest('./build/js')); | |
}); | |
//combined functionality of jsBrowserify into minify so that it works at once. This is beautiful | |
gulp.task("minifyscripts", ["jsBrowserify"], function() { | |
return gulp.src("./build/js/app.js") | |
.pipe(uglify()) | |
.pipe(gulp.dest("./build/js")); | |
}); | |
// combines functionality of build,clean,browserify,and serve. Once gulp build is run it will build,clean,bower and serve. | |
gulp.task("build", ["clean",'ts'], function() { | |
if (buildProduction) { | |
gulp.start('minifyscripts'); | |
} else { | |
gulp.start('jsBuild'); | |
} | |
gulp.start(['Bower', 'serve']) | |
gulp.start('sassBuild'); | |
}); | |
gulp.task("clean", function() { | |
return del(['build', 'tmp']); | |
}); | |
//gulp.task('jshint', function () { | |
// return gulp.src(['js/*.js']) | |
// .pipe(jshint()) | |
// .pipe(jshint.reporter('default')); | |
//}); | |
gulp.task('bowerJS', function() { | |
return gulp.src(lib.ext('js').files) | |
.pipe(concat('vendor.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./build/js')); | |
}); // takes everything and places it into the vendor js folder plus minifying. | |
gulp.task('bowerCSS', function() { | |
return gulp.src(lib.ext('css').files) | |
.pipe(concat('vendor.css')) | |
.pipe(gulp.dest('./build/css')); | |
}); | |
gulp.task('Bower', ['bowerCSS', 'bowerJS']); | |
gulp.task('serve', function() { | |
browserSync.init({ | |
server: { | |
baseDir: "./", | |
index: "index.html" | |
} | |
}); | |
gulp.watch(['js/*.js'], ['jsBuild']); //for live reloading | |
gulp.watch(['bower.json'], ['bowerBuild']); | |
gulp.watch(['*.html'], ['htmlBuild']); | |
// gulp.watch(['resources/styles/*.css', 'resources/styles/*.scss'] ['cssBuild']); | |
// gulp.watch(['app/*.ts'], ['tsBuild']); required for angular | |
}); | |
gulp.task('jsBuild', ['jsBrowserify'], function() { | |
browserSync.reload(); | |
}); | |
gulp.task('bowerBuild', ['Bower'], function() { | |
browserSync.reload(); | |
}); | |
gulp.task('htmlBuild', function() { | |
browserSync.reload(); | |
}); | |
// gulp.task('tsBuild', ['ts'], function(){ | |
// browserSync.reload(); | |
// }); | |
// // clean task | |
// gulp.task('tsClean', function(){ | |
// return del(['app/*.js', 'app/*.js.map']); | |
// }); | |
// gulp.task('ts', ['tsClean'], shell.task([ | |
// 'tsc' | |
// ])); | |
gulp.task('cssBuild', function() { | |
return gulp.src(['scss/*.scss']) | |
.pipe(sourcemaps.init()) | |
.pipe(sass()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('./build/css')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('sassBuild', function() { | |
return gulp.src(['resources/styles/*']) | |
.pipe(sourcemaps.init()) | |
.pipe(sass()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('./build/css')); | |
// }); | |
Recommended | |
// ////////////////////// DEPENDENCIES AND VARIABLES ////////////////////// | |
// var gulp = require('gulp'); | |
// // used for concatenating/minifying bower files and other js/css | |
// var concat = require('gulp-concat'); | |
// var uglify = require('gulp-uglify'); | |
// // used for pulling in bower files. | |
// var lib = require('bower-files')({ | |
// "overrides":{ | |
// "bootstrap" : { | |
// "main": [ | |
// "less/bootstrap.less", | |
// "dist/css/bootstrap.css", | |
// "dist/js/bootstrap.js" | |
// ] | |
// } | |
// } | |
// }); | |
// // used for build and clean tasks. | |
// var utilities = require('gulp-util'); | |
// var buildProduction = utilities.env.production; | |
// var del = require('del'); | |
// // set up server with watchers and run typescript compiler in the shell. | |
// var browserSync = require('browser-sync').create(); | |
// var shell = require('gulp-shell'); | |
// // sass dependencies. | |
// var sass = require('gulp-sass'); | |
// var sourcemaps = require('gulp-sourcemaps'); | |
// ////////////////////// TYPESCRIPT ////////////////////// | |
// // clean task | |
// gulp.task('tsClean', function(){ | |
// return del(['app/*.js', 'app/*.js.map']); | |
// }); | |
// // clean and then compile once. To be called from server and global build. | |
// gulp.task('ts', ['tsClean'], shell.task([ | |
// 'tsc' | |
// ])); | |
// ////////////////////// BOWER ////////////////////// | |
// // when adding a new bower depndency: | |
// // stop the server | |
// // always use the `bower install --save` flag. | |
// // run `gulp bower` to build vendor files | |
// // restart server. | |
// gulp.task('jsBowerClean', function(){ | |
// return del(['./build/js/vendor.min.js']); | |
// }); | |
// gulp.task('jsBower', ['jsBowerClean'], function() { | |
// return gulp.src(lib.ext('js').files) | |
// .pipe(concat('vendor.min.js')) | |
// .pipe(uglify()) | |
// .pipe(gulp.dest('./build/js')); | |
// }); | |
// gulp.task('cssBowerClean', function(){ | |
// return del(['./build/css/vendor.css']); | |
// }); | |
// gulp.task('cssBower', ['cssBowerClean'], function() { | |
// return gulp.src(lib.ext('css').files) | |
// .pipe(concat('vendor.css')) | |
// .pipe(gulp.dest('./build/css')); | |
// }); | |
// gulp.task('bower', ['jsBower', 'cssBower']); | |
// ////////////////////// SASS ////////////////////// | |
// gulp.task('sassBuild', function() { | |
// return gulp.src(['resources/styles/*']) | |
// .pipe(sourcemaps.init()) | |
// .pipe(sass()) | |
// .pipe(sourcemaps.write()) | |
// .pipe(gulp.dest('./build/css')); | |
// }); | |
// ////////////////////// SERVER ////////////////////// | |
// gulp.task('serve', ['build'], function() { | |
// browserSync.init({ | |
// server: { | |
// baseDir: "./", | |
// index: "index.html" | |
// } | |
// }); | |
// gulp.watch(['resources/js/*.js'], ['jsBuild']); // vanilla js changes, reload. | |
// gulp.watch(['*.html'], ['htmlBuild']); // html changes, reload. | |
// gulp.watch(['resources/styles/*.css', 'resources/styles/*.scss'], ['cssBuild']); // css or sass changes, concatenate all css/sass, build, reload. | |
// gulp.watch(['app/*.ts'], ['tsBuild']); // typescript files change, compile then reload. | |
// }); | |
// gulp.task('jsBuild', function(){ | |
// browserSync.reload(); | |
// }); | |
// gulp.task('htmlBuild', function(){ | |
// browserSync.reload(); | |
// }); | |
// gulp.task('cssBuild', ['sassBuild'], function(){ | |
// browserSync.reload(); | |
// }); | |
// gulp.task('tsBuild', ['ts'], function(){ | |
// browserSync.reload(); | |
// }); | |
// ////////////////////// GLOBAL BUILD TASK ////////////////////// | |
// // global build task with individual clean tasks as dependencies. | |
// gulp.task('build', ['ts'], function(){ | |
// // we can use the buildProduction environment variable here later. | |
// gulp.start('bower'); | |
// gulp.start('sassBuild'); | |
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "yonko", | |
"version": "1.0.0", | |
"description": "yes", | |
"main": "index.js", | |
"scripts": { | |
"test": "test" | |
}, | |
"author": "yonko steve", | |
"license": "ISC", | |
"devDependencies": { | |
"bower-files": "^3.14.1", | |
"browser-sync": "^2.18.8", | |
"browserify": "^14.1.0", | |
"del": "^2.2.2", | |
"gulp": "^3.9.1", | |
"gulp-concat": "^2.6.1", | |
"gulp-sass": "^3.1.0", | |
"gulp-sourcemaps": "^2.4.1", | |
"gulp-uglify": "^2.1.0", | |
"gulp-util": "^3.0.8", | |
"jshint": "^2.9.4", | |
"vinyl-source-stream": "^1.1.0" | |
} | |
For Angular | |
{ | |
"name": "angular2-skeleton", | |
"version": "1.0.0", | |
"scripts": { | |
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", | |
"lite": "lite-server", | |
"postinstall": "typings install", | |
"tsc": "tsc", | |
"tsc:w": "tsc -w", | |
"typings": "typings" | |
}, | |
"license": "ISC", | |
"dependencies": { | |
"@angular/common": "2.0.0-rc.6", | |
"@angular/compiler": "2.0.0-rc.6", | |
"@angular/compiler-cli": "0.6.0", | |
"@angular/core": "2.0.0-rc.6", | |
"@angular/forms": "2.0.0-rc.6", | |
"@angular/http": "2.0.0-rc.6", | |
"@angular/platform-browser": "2.0.0-rc.6", | |
"@angular/platform-browser-dynamic": "2.0.0-rc.6", | |
"@angular/router": "3.0.0-rc.2", | |
"@angular/upgrade": "2.0.0-rc.6", | |
"core-js": "^2.4.1", | |
"reflect-metadata": "^0.1.3", | |
"rxjs": "5.0.0-beta.11", | |
"systemjs": "0.19.27", | |
"zone.js": "^0.6.17", | |
"angular2-in-memory-web-api": "0.0.18", | |
"bootstrap": "^3.3.6" | |
}, | |
"devDependencies": { | |
"bower-files": "^3.11.3", | |
"browser-sync": "^2.11.1", | |
"del": "^2.2.0", | |
"gulp": "^3.9.1", | |
"gulp-concat": "^2.6.0", | |
"gulp-sass": "^2.2.0", | |
"gulp-shell": "^0.5.2", | |
"gulp-sourcemaps": "1.6.0", | |
"gulp-uglify": "^1.5.3", | |
"gulp-util": "^3.0.7", | |
"concurrently": "^2.2.0", | |
"lite-server": "^2.2.2", | |
"typescript": "^1.8.10", | |
"typings":"^1.3.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment