Skip to content

Instantly share code, notes, and snippets.

@louisremi
Last active February 15, 2016 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisremi/1ff90337edb31eee8221 to your computer and use it in GitHub Desktop.
Save louisremi/1ff90337edb31eee8221 to your computer and use it in GitHub Desktop.
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