Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 60 additions & 53 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const source = require('vinyl-source-stream')
const sass = require('gulp-sass')
const concat = require('gulp-concat')
const watchify = require('watchify')
const runSequence = require('run-sequence')
const gulpif = require('gulp-if')
const buffer = require('vinyl-buffer')
const sourcemaps = require('gulp-sourcemaps')
Expand Down Expand Up @@ -116,14 +115,16 @@ function rebundle () {
.pipe(gulp.dest(filePath.build.jsDest))
}

gulp.task('bundle-dev-once', function () {
function taskBundleDevOnce() {
bundle.bundler = dhbrowserify(bundle.conf)
bundle.prod = false
rebundle()
console.log('bundle finished')
})
}

gulp.task('bundle-dev-once', )

gulp.task('bundle-dev', function () {
function taskBundleDev() {
bundle.bundler = watchify(dhbrowserify(bundle.conf))
bundle.prod = false
bundle.bundler.on('update', rebundle)
Expand All @@ -133,47 +134,54 @@ gulp.task('bundle-dev', function () {
console.log(text)
})
return rebundle()
})
}

gulp.task('bundle-dev', taskBundleDev)

gulp.task('bundle-prod', function () {
function taskBundleProd() {
'use strict'
bundle.bundler = dhbrowserify(bundle.conf)
bundle.prod = true
return rebundle()
})
}

gulp.task('bundle-prod', taskBundleProd)

// =======================================================================
// Images Task
// =======================================================================
gulp.task('assets', function () {
function taskAssets() {
return gulp.src(filePath.assets.src)
.on('error', handleError)
.pipe(gulp.dest(filePath.assets.dest))
})
}

gulp.task('assets', taskAssets)

// =======================================================================
// Copy index.html
// =======================================================================
function copyIndex () {
function taskCopyIndex () {
return gulp.src(filePath.copyIndex.src)
.pipe(inlinesource({compress: false}))
.pipe(gulp.dest(filePath.build.dest))
}

gulp.task('copyIndex', copyIndex)
gulp.task('copyIndex', taskCopyIndex)

// =======================================================================
// Copy Favicon
// =======================================================================
gulp.task('copyFavicon', function () {
function taskCopyFavicon() {
return gulp.src(filePath.copyFavicon.src)
.pipe(gulp.dest(filePath.build.dest))
})
}
gulp.task('copyFavicon', taskCopyFavicon)

// =======================================================================
// Generate Config file
// =======================================================================
gulp.task('config', () => {
function taskConfig() {
const c = 'config.yml'
return gulp.src(c)
.pipe(expect(c))
Expand All @@ -184,92 +192,91 @@ gulp.task('config', () => {
wrap: 'module.exports = <%= module %>'
}))
.pipe(gulp.dest(filePath.destination))
})
}
gulp.task('config', taskConfig)

// =======================================================================
// Watch for changes
// =======================================================================
gulp.task('watch', function () {
function taskWatch() {
gulp.watch(filePath.styles.sass, ['sass'])
gulp.watch(filePath.styles.src, ['sass'])
gulp.watch(filePath.templates.src, ['templates'])
gulp.watch(filePath.assets.watch, ['assets'])
gulp.watch(filePath.copyIndex.watch, ['copyIndex'])
console.log('Watching...')
})
}

gulp.task('clean', function () {
gulp.task('watch', taskWatch)

function taskClean() {
return gulp.src(filePath.destination)
.pipe(clean({
force: true
force: true,
allowEmpty: true
}))
})
}

gulp.task('templates', function () {
gulp.task('clean', gulp.series(taskClean))

function taskTemplates() {
return gulp.src(filePath.templates.src)
.pipe(templateCache('templates.js', {standalone: true, moduleSystem: 'Browserify'}))
.pipe(gulp.dest(filePath.destination))
})
}

gulp.task('templates', taskTemplates)

gulp.task('_sass', function () {
function taskSass_() {
return gulp.src([filePath.styles.sass, filePath.styles.src])
.pipe(sass())
// Used to correctly compile glyphicons
// see https://github.com/sass/sass/issues/1395#issuecomment-211974664
.pipe(sassUnicode())
.pipe(concat('app.css'))
.pipe(gulp.dest(filePath.build.cssDest))
})
}

gulp.task('sass', () => {
runSequence(['_sass'], ['copyIndex'])
})
function taskSass() {
return gulp.series(taskSass_, taskCopyIndex)
}

gulp.task('vendorCSS', function () {
gulp.task('sass', taskSass)

function taskVendorCSS() {
return gulp.src(filePath.vendorCSS.src)
.pipe(concat('vendor.css'))
.on('error', sass.logError)
.pipe(gulp.dest(filePath.build.cssDest))
})
}

gulp.task('vendorCSS', taskVendorCSS)

// =======================================================================
// Copy Fonts
// =======================================================================
gulp.task('copyFonts', function () {
function taskCopyFonts() {
return gulp.src(filePath.copyFonts.src)
.pipe(gulp.dest(filePath.copyFonts.dest))
})
}

gulp.task('copyFonts', taskCopyFonts)

// =======================================================================
// Sequential Build Rendering
// =======================================================================

// run "gulp" in terminal to build the DEV app
gulp.task('build-dev', function (callback) {
runSequence(
// images and vendor tasks are removed to speed up build time. Use "gulp build" to do a full
// re-build of the dev app.
['config', 'templates'],
['bundle-dev', '_sass'],
['copyIndex'],
['watch'],
callback
)
})
gulp.task('build-dev', gulp.series(taskConfig, taskTemplates, taskBundleDev, taskSass_, taskCopyIndex, taskWatch))

// run "gulp build" in terminal for a full re-build in DEV
gulp.task('build', function (callback) {
runSequence(
['clean'],
['config', 'templates'],
['bundle-dev', 'vendorCSS', '_sass', 'assets', 'copyFavicon', 'copyFonts', 'copyIndex'],
callback
)
})
gulp.task('build',
gulp.series(taskClean, taskConfig, taskTemplates, taskBundleDev, taskVendorCSS,
taskSass_, taskAssets, taskCopyFavicon, taskCopyFonts, taskCopyIndex))

// run "gulp prod" in terminal to build the PROD-ready app
gulp.task('build-prod', function (callback) {
runSequence(
gulp.series(
['clean'],
['config', 'templates'],
['bundle-prod', 'vendorCSS', '_sass', 'assets', 'copyFavicon', 'copyFonts', 'copyIndex'],
Expand All @@ -281,7 +288,7 @@ gulp.task('build-prod', function (callback) {
// Documentation
// =======================================================================

gulp.task('docs', [], function () {
gulp.task('docs', function () {
const gulpDocs = require('gulp-ngdocs')
return gulp.src('./app/**/*.js')
.pipe(gulpDocs.process())
Expand Down Expand Up @@ -312,7 +319,7 @@ gulp.task('unit-test-once', done => {
* Runs the selenium server.
*/
gulp.task('Run Selenium', callback => {
runSequence(['_webdriverUpdate'], ['_runSelenium'], callback)
gulp.series(['_webdriverUpdate'], ['_runSelenium'], callback)
})
gulp.task('_webdriverUpdate', gulpProtractor.webdriver_update)
gulp.task('_runSelenium', gulpProtractor.webdriver_standalone)
Loading