mirror of
https://github.com/atlanticbiomedical/website.git
synced 2025-07-01 18:07:27 -04:00
Moved everything into a folder
This commit is contained in:
154
biomed-frontend/gulpfile.js
Normal file
154
biomed-frontend/gulpfile.js
Normal file
@ -0,0 +1,154 @@
|
||||
var gulp = require('gulp');
|
||||
var clean = require('gulp-clean');
|
||||
var concat = require('gulp-concat');
|
||||
var uglify = require('gulp-uglify');
|
||||
var ngAnnotate = require('gulp-ng-annotate');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var templates = require('gulp-angular-templatecache');
|
||||
var streams = require('event-stream');
|
||||
var sass = require('gulp-sass');
|
||||
var plumber = require('gulp-plumber');
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
||||
gulp.task('build', ['js', 'vendor', 'html', 'styles', 'assets']);
|
||||
|
||||
gulp.task('clean', function() {
|
||||
gulp.src('build')
|
||||
.pipe(clean());
|
||||
});
|
||||
|
||||
gulp.task('vendor', function() {
|
||||
gulp.src([
|
||||
'vendor/jquery/dist/jquery.min.js',
|
||||
'vendor/angular/angular.min.js',
|
||||
'vendor/angular-loading-bar/build/loading-bar.js',
|
||||
'vendor/angular-resource/angular-resource.js',
|
||||
'vendor/angular-sanitize/angular-sanitize.js',
|
||||
'vendor/angular-ui-router/release/angular-ui-router.js',
|
||||
'vendor/lodash/dist/lodash.js',
|
||||
'vendor/masonry/dist/masonry.pkgd.js',
|
||||
'vendor/angular-masonry/angular-masonry.js',
|
||||
'vendor/imagesloaded/imagesloaded.pkgd.js'
|
||||
])
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(concat('vendor.js'))
|
||||
.pipe(sourcemaps.write({sourceRoot: '/vendor'}))
|
||||
.pipe(gulp.dest('build'));
|
||||
});
|
||||
|
||||
gulp.task('js', function() {
|
||||
var html = gulp.src(['src/**/*.html', '!src/index.html'])
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(templates({ standalone: true }));
|
||||
|
||||
var js = gulp.src(['src/**/imdex.js', 'src/**/*.js'])
|
||||
.pipe(plumber())
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(concat('src.js'))
|
||||
.pipe(ngAnnotate())
|
||||
.pipe(uglify());
|
||||
|
||||
streams.merge(html, js)
|
||||
.pipe(concat('app.js'))
|
||||
.pipe(sourcemaps.write({sourceRoot: '/src'}))
|
||||
.pipe(gulp.dest('build'));
|
||||
});
|
||||
|
||||
gulp.task('styles', function() {
|
||||
var processWinPath = function(file) {
|
||||
var path = require('path');
|
||||
if (process.platform === 'win32') {
|
||||
file.path = path.relative('.', file.path);
|
||||
file.path = file.path.replace(/\\/g, '/');
|
||||
}
|
||||
};
|
||||
|
||||
gulp.src([
|
||||
'src/styles/styles.scss',
|
||||
])
|
||||
.on('data', processWinPath)
|
||||
.pipe(plumber())
|
||||
.pipe(sass({
|
||||
includePaths: [
|
||||
'vendor/foundation/scss',
|
||||
],
|
||||
// sourceComments: 'map'
|
||||
}))
|
||||
.pipe(sourcemaps.init({loadMaps: true}))
|
||||
.pipe(concat('styles.css'))
|
||||
.pipe(sourcemaps.write({sourceRoot: '/src/../'}))
|
||||
.pipe(gulp.dest('build'));
|
||||
});
|
||||
|
||||
gulp.task('html', function() {
|
||||
gulp.src('src/index.html')
|
||||
.pipe(gulp.dest('build'));
|
||||
});
|
||||
|
||||
gulp.task('assets', function() {
|
||||
gulp.src('src/assets/**/*')
|
||||
.pipe(gulp.dest('build/assets'));
|
||||
});
|
||||
|
||||
gulp.task('watch', ['js'], function() {
|
||||
gulp.watch('src/**/*.js', ['js']);
|
||||
});
|
||||
|
||||
function startExpress() {
|
||||
var express = require('express');
|
||||
var request = require('request');
|
||||
var fs = require('fs');
|
||||
var app = express();
|
||||
|
||||
app.use(require('connect-livereload')());
|
||||
|
||||
app.use('/api', express.static(__dirname + '/demo', {
|
||||
index: ['index.json']
|
||||
}));
|
||||
app.use('/demo', express.static(__dirname + '/demo'));
|
||||
app.use(express.static('build'));
|
||||
|
||||
/*
|
||||
app.all('/api/*', function(req, res) {
|
||||
var url = 'http://localhost:8080' + req.url;
|
||||
req.pipe(request(url)).pipe(res);
|
||||
});
|
||||
*/
|
||||
|
||||
app.all('/*', function(req, res) {
|
||||
res.sendFile('index.html', { root: 'build' });
|
||||
});
|
||||
|
||||
app.listen(5000);
|
||||
}
|
||||
|
||||
var lr;
|
||||
|
||||
function startLiveReload() {
|
||||
lr = require('tiny-lr')();
|
||||
lr.listen(35729);
|
||||
}
|
||||
|
||||
function notifyLiveReload(event) {
|
||||
var filename = require('path').relative('build', event.path);
|
||||
|
||||
lr.changed({
|
||||
body: {
|
||||
files: [filename]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('server', ['build'], function() {
|
||||
startExpress();
|
||||
startLiveReload();
|
||||
|
||||
gulp.watch(['src/**/*.js', 'src/**/*.html'], ['js', 'html']);
|
||||
gulp.watch('src/**/*.scss', ['styles']);
|
||||
gulp.watch('vendor/**/*', ['vendor', 'styles']);
|
||||
gulp.watch('src/assets/**/*', ['assets']);
|
||||
gulp.watch('build/**/*', notifyLiveReload);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user