Last active
February 15, 2016 22:01
-
-
Save louisremi/1ff90337edb31eee8221 to your computer and use it in GitHub Desktop.
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
const gulp = require('gulp'); | |
const shelter = require('gulp-shelter')(gulp); | |
const BRANCH = process.env.TRAVIS_BRANCH; | |
// project config | |
const project = 'projectName'; | |
const main = `src/main.js`; | |
const dest = `dist/${project}.js`; | |
const domain = ( | |
BRANCH === 'master' ? 'www.domain.com' : | |
BRANCH === 'develop' ? 'dev.domain.com' : | |
false | |
); | |
// commands and fragments | |
const browserifyOpts = ` | |
--standalone ${project} | |
--transform [ babelify --presets [ es2015 react ] ] | |
--debug`; // --debug enables source-map | |
const browserify = `browserify ${main} ${browserifyOpts}`; | |
const exorcist = `exorcist ${dest}.map > ${dest}`; | |
const watchify = `watchify ${main} ${browserifyOpts} -o ${dest}`; | |
const browsersync = `browser-sync start --server --files "${dest}, index.html"`; | |
const surge = domain ? `surge --project ./dist --domain ${domain}` : ':'; // ':' is noop in bash | |
// tasks definitions | |
shelter({ | |
build: { | |
dsc: `generate ${project} lib and external source-map`, | |
cmd: `${browserify} | ${exorcist}` | |
}, | |
serve: { | |
dsc: 'Open index.html and live-reload on changes', | |
cmd: `${watchify} & ${browsersync}` | |
}, | |
deploy: { | |
dsc: 'Run by Travis to automatically deploy on Surge', | |
cmd: `${browserify} | ${exorcist} && ${surge}` | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment