Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Last active May 21, 2016 23:02
Show Gist options
  • Save dhigginbotham/562dfe273fd663f94bc37587b38aa77a to your computer and use it in GitHub Desktop.
Save dhigginbotham/562dfe273fd663f94bc37587b38aa77a to your computer and use it in GitHub Desktop.
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
// path prefix
const prefix = 'assets/';
const vendorPrefix = `${prefix}src/vendor/`;
const bowerPrefix = `${prefix}src/bower/`;
const files = {
vendor: [],
library: [],
libraryAdmin: [
`${prefix}src/app/main.js`
],
vendorAdmin: [
`${vendorPrefix}jshint.js`,
`${vendorPrefix}codemirror-5.14.2/lib/codemirror.js`,
`${vendorPrefix}codemirror-5.14.2/mode/javascript/javascript.js`,
`${vendorPrefix}codemirror-5.14.2/addon/selection/active-line.js`,
`${vendorPrefix}codemirror-5.14.2/addon/edit/matchbrackets.js`,
`${vendorPrefix}codemirror-5.14.2/addon/lint/lint.js`,
`${vendorPrefix}codemirror-5.14.2/addon/lint/javascript-lint.js`,
`${bowerPrefix}pikaday/pikaday.js`
],
productionAdmin: [
`${prefix}build/js/vendorAdmin.min.js`,
`${prefix}build/js/libraryAdmin.min.js`
],
productionClient: [
`${prefix}build/js/vendor.min.js`,
`${prefix}build/js/library.min.js`
]
};
const css = [
`${bowerPrefix}baseless/dist/style.min.css`,
`${vendorPrefix}codemirror-5.14.2/lib/codemirror.css`,
`${vendorPrefix}codemirror-5.14.2/theme/neo.css`,
`${vendorPrefix}codemirror-5.14.2/addon/lint/lint.css`,
`${bowerPrefix}pikaday/css/pikaday.css`,
`${prefix}src/css/container.css`,
`${prefix}src/css/custom.css`
];
Object.keys(files).forEach((file) => {
gulp.task(file, () => {
gulp.src(files[file])
.pipe(uglify())
.pipe(concat(`${file}.min.js`))
.pipe(gulp.dest(`${prefix}build/js`));
});
});
gulp.task('css', () => {
gulp.src(css)
.pipe(concat('style.min.css'))
.pipe(gulp.dest(`${prefix}build/css`));
});
gulp.task('watch', () => {
Object.keys(files).forEach((file) => gulp.watch(files[file], [file]));
gulp.watch(css, ['css']);
});
const uberTasks = Object.keys(files);
uberTasks.push('watch');
gulp.task('uber', uberTasks);
gulp.task('default', uberTasks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment